Combinatorics problem involving matrices Let us consider a matrix whith $m$ rows and $n$ columns which is filled only with $1$ and $-1$. What is the number of these matrices such that the product of the elemnts from each row and column is $-1$?
 A: Let $A = (a_{ij})$ be such an $m \times n$ matrix of $1$s and $-1$s. Consider the product $\prod a_{ij}$ of all the entries. On the one hand, computing the product one row at a time, this is $(-1)^m$. Computing one column at a time yields $(-1)^n$. So, from $(-1)^m = (-1)^n$, we conclude that, in order for such a matrix to exist, $m$ and $n$ must have the same parity.
Now let $m,n$ be positive integers of the same parity. We construct all the desired $m \times n$ matrices $A = (a_{ij})$. First, choose $(a_{ij})$ arbitrarily when $1 \leq i \leq m-1$ and $1 \leq j \leq n-1$. There are $2^{(m-1)(n-1)}$ ways to form this $(m-1) \times (n-1)$ submatrix. Now, in order to guarantee that the first $m-1$ rows and first $n-1$ columns have product $-1$, we are forced to assign
\begin{align*}
a_{in} = (-1) \prod_{j=1}^{n-1} a_{ij} && \text{ for } 1 \leq i \leq m-1 \\
a_{mj} = (-1) \prod_{i=1}^{m-1} a_{ij} && \text{ for } 1 \leq j \leq n-1 
\end{align*}
It remains only to choose the last entry $a_{mn}$ in such a way that the final row and final column each have product $-1$. On the one hand, for the last row to work out, we need to take
$$a_{mn} = (-1) \prod_{j=1}^{n-1} a_{mj} = (-1)^n P_{m-1,n-1}$$
where $P_{m-1,n-1}$ denotes the product of the entries of the upper left $(m-1) \times (n-1)$ submatrix. Similarly, to make the final column work out, we need to take 
$$a_{mn} = (-1)^m P_{m-1,n-1}.$$
Fortunately, we assumed $m$ and $n$ have the same parity, so these choices are consistent. 
In conclusion, the number of $m \times n$ matrices of the desired type is $0$ if $m \neq n \pmod{2}$ or $2^{(m-1)(n-1)}$ if $m = n \pmod{2}$. In the latter case, one can choose the $(m-1) \times (n-1)$ submatrix arbitrarily, and this choice determines the entries in the final column and row.
