I find this a rather awkward question, and I was given a hint: use invariants, which I found even more awkward.
Suppose $M$ is an $m \times n$ matrix such that all rows and columns of $M$ sum to $1$. Show that $m=n$.
I have no clue how this is a problem on invariants, let alone how to solve this problem. I'll need hints on why this is the case.