Олимпиадный тренинг

Задача 38334. simple square


Petya has a playing field of 3x3 size, filled with numbers from 1 to 9. At the beginning of the game, he can place a chip in any cell of the field. At each step of the game, it is allowed to move a piece to any cell adjacent to the side, but it is not allowed to visit the same cell twice. Petya carefully keeps the protocol of the game, writing down the numbers in it in the order in which the chip visited the cells. Petya was wondering what is the maximum number he can get in the protocol. Help him answer this question.

Input
The input file contains the description of the — 3 lines of 3 integers separated by spaces. It is guaranteed that all nine numbers are different and lie in the range from 1 to 9.

Imprint
Print a single integer — the maximum number that could result in the protocol when playing on this field.

The answer can be displayed not as a number, but as a string or as a sequence of individual digits (but not separated by spaces).
Examples
# Input Output
1 1 2 3
4 5 6
7 8 9
987456321