when you're trying to cut the bar of chocolate in every horizental and vertical way, you also need to try to take every possible number of chocolate squares from the new chocolate bar.so you're looping over k and trying to take every possible number of chocolate squares every time you cut the chocolate bar