We want to form a square nxn (n>2) binary matrix whose each entry is either 0 or 1.But the rule states that there must be at least one 0 and one 1 in each row and in each column. In how many ways can we do this for a general integer n?

Here i tried to count the number of ways we can form a row or a column consisting only of 0's and only of 1's, and then subtract it from the total number of ways we can have a binary matrix without a restriction, but unfortunately i could not. What is your take on this problem?