Find number of matrices $B$ with no common row and no common column with a given matrix $A$

29 Views Asked by At

We are given a matrix $A$ with $n$ rows and $n$ columns and it's elements are $1,2,...,n^2$ (each element appears once). Find the number of matrices $B$ whose elements are $1,2,...,n^2$ that does not share a common row or a common column with $A$ (if it is not clear, we can't have the second row of $B$ to be equal to the fifth row of $A$, the non-equal rows (and columns) do not have to share index).
I am pretty sure this uses inclusion-exclusion but I don't know how to approach it. Any idea? Thanks