The equivalence classes of $N\sim M\Leftrightarrow G/N\cong G/M$.

Solution 1:

There is a special case of your question that plays an essential role in the $p$-group generation algorithm. It should be Theorem 2.5 there.