Number of ways to fill 1,2,3,4 in an array so that the sum of each row & column is divisible by 4 There is a 4X4 array each entry of which can be filled with the numbers 1,2,3,4. In how many ways can we fill the array such that the sum of each row and each column is divisible by 4?
 A: The answer should be 4^9.  3 rows and 3 columns have one entry that is chosen to make that row/column divisible by 4.  One more cell is chosen so that the calculated rows and columns are divisible by 4.  4 options for the basic cells.
a a a b
a a a b
a a a b
c c c d
Each cell labeled a can be 1,2,3 or 4.  Each cell labeled b chosen so that its row is divisible by 4.  Each cell labeled c is chosen so that its column is divisible by 4.  d can be chosen either way and will be the same.
A: 4^9.
More generally:
In how many ways can a $X \times Y$ be filled by values $1 .. N$ such that the sum in each row and column is divisible by $N$?
$N^{(X-1)(Y-1)}$
Choose all values in all cells except the last row and column arbitrarily and independently (giving the figure above).
Choose the values in the last row such that the column sums are correct (one way, always possible).
Choose the values in the last column such that the row sums are correct (one way, always possible).
Since the sum of the row sums is always equal to the sum of the column sums, so the same value in the bottom-right that sets the last row to be divisible by four will also set the last column to be divisible by four
