Let $M$ be the set of $m \times n$ real matrices. Consider the following equivalence relation: $A, B$ are equivalent if there exists a real invertible $m\times m$ matrix $P$ and a real invertible $n \times n$ matrix $Q$ such that $A=PBQ$. Find out into how many disjoint equivalence classes if $M$ partitioned by this equivalence relation.
I know that in case of square matrices, two similar matrices have same rank. Is the given problem somehow related with rank? Please help in solving this problem.