Problem A. Array access

Author:A. Klenin   Time limit:1 sec
Input file:input.txt   Memory limit:256 Mb
Output file:output.txt  

Statement

During the course on compiler construction, students were assigned a task: implement a parser for expressions with array access according to Pascal programming language syntax. Student Vasya has slacked on this task, and implemented only a very small language subset, consisting of a single integer constant 0 and accesses to a single two-dimensional array a. In other words, his "language" has the following grammar:

  expr ::= 0 | a[expr,expr]

After seeing this sad result, a teacher assigned an additional task to Vasya: suppose an array a is defined as a: array [0..N - 1, 0..N - 1] of 0..N. Given N and the values of array elements, generate the shortest possible expression in Vasya's language which will have the value of N.

Input file format

Input file contains an integer N, followed by N2 integers — values aij, in row-by-row order.

Output file format

Output file must contain a single string — an expression in Vasya's language. The expression must exactly correspond to the grammar above. If there is no expression with the value of N, output string IMPOSSIBLE. If there are several shortest expressions, output any of them.

Constraints

1 ≤ N ≤ 22, 0 ≤ aij ≤ N

Sample tests

No. Input file (input.txt) Output file (output.txt)
1
2
1 2
0 0
a[0,a[0,0]]
2
3
2 0 0
0 3 0
0 0 0
IMPOSSIBLE

0.080s 0.011s 13