The game of Tobo is played on a plastic board designed into a 3 ×
A" to
D" in the figure.) Each dial can be rotated in 90 degrees increment in either direction. Rotating a dial causes the four cells currently adjacent to it to rotate along. For example, figure (b) shows the Tobo after rotating dial A" once in a clockwise direction. Figure (c) shows the Tobo in figure (b) after rotating dial
D" once in a counterclockwise direction.
Kids love to challenge each other playing the Tobo. Starting with the arrangement shown in figure (a), (which we'll call the standard arrangement,) one kid would randomly rotate the dials, X
Your program will be tested on one or more test cases. Each test case is specified on a line by itself. Each line is made of 10 decimal digits. Let's call the first digit Y
The last line of the input file is a sequence of 10 zeros.
For each test case, print the result using the following format:
k
.
R
where k
is a single space, and R
3413569728
1165432789
0000000000
1. 2
2. -1
Migrated from old NTUJ.
Arab & North Africa 2008
No. | Testdata Range | Score |
---|