
Following the hype generated by the Rubik's Cube Norwegian Open Championship arranged at NTNU this year, each and every student at NTNU has bought such a cube. The professors, however, are dismayed, because the students would rather play with their cube instead of listening to the professors' lectures.
One professor suddenly gets the idea that if he gives the students a program to solve their cubes, they may lose interest in them, so that it will be possible to start teaching again. Of course, the professor doesn't want to do the grunt work of programming, and you are the lucky assignee of this task. The professor takes away your cube, locks you in a faraway laboratory, and says that you won't get out until you have written a program to solve Rubik's Cube.
Luckily, the professor did not specify the size of the cube, so you decide to make the work slightly easier by solving the Rubik's 2 \times 2 \times 2 cube.
The first line contains the number of test cases (0 < T \leq 100). Each test case consists of six lines describing the initial configuration of a cube, formatted exactly as in the example input. The characters used for colors are G, R, O, B, Y, and W. Each test case is followed by an empty line.
You may assume that all input cubes are scrambled versions of originally solved cubes with six different colors. (This means there are exactly four occurrences of each color, and that it is possible to get the cube to a solved state using moves as described below.)
For each test case, output a line with the minimum number of moves necessary to solve the cube. A move is turning one face of the cube degrees clockwise or counterclockwise. A turn of degrees is considered to be two moves.
Example 1