Counting matrices over $\mathbb{Z}/2\mathbb{Z}$ with conditions on rows and columns I want to solve the following seemingly combinatorial problem, but I don't know where to start.
How many matrices in $\mathrm{Mat}_{M,N}(\mathbb{Z}_2)$ are there such that the sum of entries in each row and the sum of entries in each column is zero? More precisely find cardinality of the set
$$
\left\{A\in\mathrm{Mat}_{M,N}(\mathbb{Z}/2\mathbb{Z}): \forall j\in\{1,\ldots,N\}\quad \sum\limits_{k=1}^M A_{kj}=0,\quad \forall i\in\{1,\ldots,M\}\quad \sum\limits_{l=1}^N A_{il}=0  \right\}
$$.
Thanks for your help.

If you consider the entries of the matrices as unknowns, you have $N\cdot M$ unknowns and $N+M$ linear equations.
If you think a little bit, you find out that these equations are not independent, but you get linearly independent equations if you omit one of them.
So the solution space has the dimension $NM-N-M+1$, hence it contains $2^{MN-N-M-1}=2^{(N-1)(M-1)}$ elements.
