|Matrices are a common object in mathematics. A NxM matrix is basically a table with N rows of M values each. Given two matrices, one of size AxB and another of size CxD, the following multiplication rules apply:
Given a list of matrices, determine if there's an ordering that allows you to multiply all of them. If multiple such orderings exist, choose the one where the result has the most elements. Return the number of elements in the result, or -1 if there is no valid ordering (see examples 0-3 for further clarification). The list of matrices is given as two ints, N and M, where the ith elements of N and M represent the number of rows and columns respectively of the ith matrix.
|-||The association order is not important because we are only interested in the dimensions of the matrices.|
|-||M will have between 1 and 50 elements, inclusive.|
|-||N and M will have the same number of elements.|
|-||Each element of N and M will be between 1 and 1000, inclusive.|