Snake

No attempts yetTime limit3sMemory limit512 MB

Problem

A snake fills a 3×n3 \times n board with no empty squares. The snake's squares are numbered from 11 to 3n3n in order. Squares with consecutive numbers (11 and 22, 22 and 33, 33 and 44, \ldots) share an edge.

A snake can fill a 3×93 \times 9 board as follows, for example.

Some of the numbers have been erased. Reconstruct the snake.

Input

The first line contains a single integer nn (1n10001 \le n \le 1000), the length of the board.

The next three lines describe the board. The ii-th of these lines contains nn integers aija_{ij} (0aij3n0 \le a_{ij} \le 3n for 1jn1 \le j \le n).

If aij>0a_{ij} > 0, then aija_{ij} is the number of the snake segment on the jj-th square of the ii-th row. If aij=0a_{ij} = 0, the number on that square is unknown.

Output

Print three lines. The ii-th line should contain nn positive integers bijb_{ij} (for 1jn1 \le j \le n), separated by spaces. Together, the numbers bijb_{ij} must be a permutation of 1,2,,3n1, 2, \ldots, 3n.

The output must agree with every positive number in the input, and squares that hold consecutive numbers must share an edge.

A valid reconstruction always exists, and it is unique.