
Not that amazing, I didn't remember it at all. I just remembered having made a little mental breakthrough in solving it during the match in which it was used, and figured that since I remembered getting it right, my rating probably went up. Then I went and looked at my rating graph and started checking the matches where I went up recently, and I found it.
Well, one of two conditions exist, in the case that there are multiple ways to multiply all the matrices, the reason there are multiple ways is that there's a potential "cycle" somewhere (although there may even be multiple cycles, but that's not so important in the end). Because of that, we can rotate the order to maximize the size of the matrix, which will start with the largest thing in M and end with the largest thing in N (and that M and N will be equal).
The tricky part here is figuring out if there is such a condition, and doing that has two parts:
Can the numbers in M match up with the numbers in N? How many numbers x are there such that there are a different number of x's in M and N? There is definitely no answer if there is more than one number that occurs more in M than N or more than one number that occurs more in N than M (or if there is two more of that number in M than N or vice versa).
If they can match up, is there a way to reach every matrix from every matrix? If you think of the input as a graph (where each M[i], N[i] pair is a directed edge), the answer is basically yes if the entire graph is strongly connected. You'll notice that the M's and N's match up in example 3, but the graph isn't strongly connected  it has two separate strongly connected components, therefore there's no way of putting them together.
After that, there is only one way to set up an order if there was a spare element in M and N that isn't matched in the other. The answer in this case is the product of those spare elements (example 1 does this). If M and N matched up perfectly, then we can pick any number to be both the beginning and end, so we pick the largest one, and the square of the largest element in M/N is our answer (see example 0 or 4).
A better description from the standpoint of graph theory as well as why it works can be found in the editorial for that match. 