Now tazigo would like to ask you whether you can multiply all matrices which are represented by tuple . You can calculate the number in all possible ways to multiply all matrices. Notice that, two matrices are different if and only if their positions in the input sequence are different.
If there are more than one solution, please print the matrix multiplication sequence represented by dimension tuples, whose order is the least lexicographical order.
The first line is an integer nstands for the number of the matrices.
Every line of the following n lines contains two integerrepresenting the number of rows and the number of columns of the ith matrix.(
)
Print an integer in the first line, representing the number of all possible ways to multiply all matrices. If the answer exists, the sequence of dimension tuples in the least lexicographical order must be output in the second line.