Cut a rectangle into rows and columns of equal squares