Vova was walking along the Statue Square (皇后像廣場) in Hong Kong, when he
noticed that the square was paved with multi-colored square tiles. Vova
took a careful look at the tiles and realized that they formed some picture.
The tiles were large and he couldn't look at all of them at once. Probably
one should look at the tile picture from above.
Vova decided to take a photo of a (10 × 10)-tile part of a picture,
but he still couldn't cover them with one shot. Then Vova took nine
photos, each of them covered a (4 × 4)-tile area of the picture (see
the picture below). If we arrange the nine photos correctly, then we can
restore the original 10 × 10 picture.
Unfortunately, soon after printing out the photos Vova forgot not only the
arranging order of them, but the correct rotation as well. He can rotate the image
on the photo by an arbitrary angle multiple of 90 degrees. Help Vova use
the nine photos to restore the original 10 × 10 pattern.
Input
The input contains the nine photos Vova made. The photos are described by
4 × 4 size matrices containing integers from 0 to 99, representing
the colors of the corresponding tiles. The numbers on a line are separated
by spaces. Each matrix is separated from the next one by an empty line.
Output
Print the original pattern as a 10 × 10 matrix. The matrix elements
in the line should be separated by spaces. If there are multiple
solutions, you may print any of them. It is guaranteed that at least one
solution exists.
Sample
input | output |
---|
1 1 9 9
1 9 1 1
9 1 1 1
9 1 1 9
9 1 1 9
9 1 1 1
9 1 1 1
9 1 1 9
9 1 1 9
9 1 1 1
1 9 1 1
1 1 9 9
9 1 1 9
1 1 1 1
1 1 1 1
9 1 1 9
9 1 1 9
1 1 1 9
1 1 9 1
9 9 1 1
9 1 1 9
1 1 1 9
1 1 1 9
9 1 1 9
9 9 1 1
1 1 9 1
1 1 1 9
9 1 1 9
9 9 9 9
1 1 1 1
1 1 1 1
9 1 1 9
9 1 1 9
1 9 9 1
1 1 1 1
9 9 9 9
| 1 1 9 9 9 9 9 9 1 1
1 9 1 1 1 1 1 1 9 1
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 1 1 1 1 1 1 9
9 1 1 9 1 1 9 1 1 9
9 1 1 1 9 9 1 1 1 9
1 9 1 1 1 1 1 1 9 1
1 1 9 9 9 9 9 9 1 1
|
Problem Source: Open Ural FU Personal Contest 2013