Given two matrices A and B, matrix C = AB can be computed using the standard rules of matrix multiplication:

The number of columns in matrix A must be equal to the number of rows in matrix B. Let matrix A have size m \times n and matrix B have size n \times p. Then, matrix C will have size m \times p and to compute C you need to perform m \times n \times p multiplications.

For example, if A has size 10 \times 20, and B has size 20 \times 15, then 10 \times 20 \times 15 = 3000 multiplications are needed to compute C.

Multiplication of several matrices can be done in different ways. For example, if we have matrices X, Y, and Z, the product XYZ can be computed either as or as . Suppose X has size 5 \times 10, Y has size 10 \times 20, and Z has size 20 \times 35.

Let's calculate the number of multiplications required for each approach:
5 \times 20 \times 10 = 1000 multiplications to determine , which will be 5 \times 20.
Then 5 \times 35 \times 20 = 3500 multiplications to compute the final result.
Total: multiplications.
10 \times 35 \times 20 = 7000 multiplications to determine , which will be 10 \times 35.
Then 5 \times 35 \times 10 = 1750 multiplications to compute the final result.
Total: multiplications.
It is clear that computing requires fewer multiplications.

Given a sequence of matrices to be multiplied, determine the optimal order of multiplication. The optimal order is the sequence that minimizes the total number of scalar multiplications.
Each test consists of a sequence of matrices, described only by their sizes. Each test contains (n \leq 10), the number of matrices, followed by pairs of integers describing the sizes of the matrices (number of rows and columns), given in the order in which the matrices are multiplied. The last test contains n = 0 and should not be processed.
Let the matrices be numbered A1, A2, ..., An. For each test, output its number and a parenthesized expression indicating the optimal multiplication order. The tests are numbered starting from . The output format must match the example exactly. If there are several optimal orders of multiplication, print any of them.
Example 1