Find the number of ways to fill up a square with $1,-1$ such that each $2\times 2$ submatrix adds up to $0$ Find the number of ways to fill up a $n \times n$ matrix with $\{1,-1\}$ such that each $2\times2$ submatrix adds up to $0$.
I cannot really think of a way to begin with it.
 A: Suppose we are to fill an $m$-by-$n$ table using the same rule (i.e., the table has $m$ rows and $n$ columns).  We shall prove that there are in total $2^m+2^n-2$ ways to fill the table.  If $m=n$, then the answer is $2^{n+1}-2$.
Consider the first (topmost) row of table.  If there are two adjacent squares with the same number, then observe that the second row is uniquely determined by the first row.  The second row then has two adjacent cells with the same number (as it must be obtained from the first row via switching signs).  Therefore, there is also a unique way to fill in the third row.  So on and so forth, this implies that, for a given top row with two adjacent squares filled with the same number, the other rows are unique.  There are $2^n$ ways to fill in the first row, but only $2$ ways to make the numbers alternating.  Thus, there are $2^n-2$ ways to fill the top row with two adjacent squares having the same number.
Now suppose that we are in the situation where the top row does not have two adjacent squares with the same number (there are $2$ ways to choose this top row).  Observe that there are $2$ ways to choose the second row.  The second row will be alternating as well.  Thus, there are also $2$ ways to choose the third row.  So on and so forth, we conclude that in this given situation, there are exactly $2^m$ possible ways to fill the table.  Including the previous paragraph, the total number of ways to fill in the table is $2^m+2^n-2$.
