Colouring 4 sections of a $3 \times 3$ grid with two colours. Let's say there is a $3 \times 3$ grid of squares. You colour any one of those squares green, then you colour another square that isn't coloured and is neither on the same row nor column as the first square.
You then colour a non-coloured square blue and then finally colour another square that isn't coloured and isn't on the same row nor column as the other blue square. In how many ways can this be done?(The order in which squares are coloured doesn't matter, only the end state of the grid)
-You may not colour over coloured squares.
-Squares cannot be coloured in the same row or column as another square of the same colour.
How many ways can this be done on a $n \times n$ grid with m colours and l squares painted with each colour?
I saw this question on a multiple choice test, since you have nine options to choose for the first square it follows that the answer should be a multiple of nine and only one of the choices was a multiple of nine, which is kind lame, The number of combinations for the last square depends on every square coloured before it so it was hard for me to think about all the possible valid moves, I do think only half of the squares chosen for the last square will be valid on average but i'm not very confident.
 A: For the case where $m=2$ and $l=2$ on an $n\times n$ grid, it follows that there are $n^2$ first squares to color $m_1$, and then, since we have removed one row and one column of available squares, there are $(n-1)^2$ second squares to color $m_1$.
Then, when coloring squares with our second color, $m_2$, we have $n^2-2$ squares to choose from at first. We can break this down into three categories: either our square shares a row and column with both of our $m_1$ squares, our square shares a row or column with one of the $m_1$ squares but not the other, and our square shares neither a row nor a column with either of the $m_1$ squares. Going category by category:

*

*There are only 2 squares such that our first $m_2$ square shares a row and column with each of the $m_1$ squares. Choosing one of these squares leaves $n^2-3-2(n-2)=n^2-2n+1=(n-1)^2$ squares for our second $m_2$ square.

*There are then $4(n-1)-2=4n-6$ squares that share a row or column with one $m_1$ squares but not the other. This would leave $n^2-3-(n-2)-(n-1)=n^2-2n$ squares for our second $m_2$ square.

*Finally, we must conclude that there are $n^2-2-(4n-6)=n^2-4n+4=(n-2)^2$ squares that share neither a row nor a column with any $m_1$ squares. This leaves $n^2-3-2(n-1)=n^2-2n-1$ squares for our second $m_2$ square.

And, of course, since the order we choose the squares in does not matter, we can divide the whole thing by 4.
Therefore, in total, the number of ways to color 4 squares of an $n\times n$ grid with two colors such that no two squares in the same row or column have the same color is:
$\frac{1}{4}n^2(n-1)^2[2(n-1)^2+(4n-6)(n^2-2n)+(n-2)^2(n^2-2n-1)]$
which WolframAlpha mercifully simplifies down to
$\frac{1}{4}n^2(n-1)^4(n^2-2)$
I will concede that I do not know how to generalize this for arbitrary $m$ and $l$ yet, but I do not imagine it would be much more work than this.
