A very well-known toy/pastime, called Rubik's cube, consists of a cube as shown in Figure 1a, where letters stand for colors (e.g. B for blue, R for red,...). The goal of the game is to rotate the faces of the cube in such a way that at the end each face has a different color, as shown in Figure 1b. Notice that,
The input contains several test cases. The first line of the input is an integer which indicates the number of tests. Each test description consists of ten lines of input. The first nine lines of a test will describe an initial configuration, in the format shown in Figure 3a. The next line will contain a list of rotations, ending with the value 0.
For each test case your program should print one line. If your grandpa is correct, print "Yes,grandpa!", otherwise print "No, you are wrong!".
3 G Y Y G Y Y G Y Y W W W Y R R M M M G G B W W W Y R R M M M G G B W W W Y R R M M M G G B R B B R B B R B B -1 0 G Y Y G Y Y G Y Y W W W Y R R M M M G G B W M W Y R R M W M G G B W W W Y R R M M M G G B R B B R B B R B B -1 0 M W M W W G W W Y G Y Y M M B M B G W R B B Y Y M M B M G G W R R Y M G W B B R R G R R W R Y Y G B Y R G B +4 +6 -2 +3 -4 +2 -3 -6 0
Yes, grandpa! No, you are wrong! Yes, grandpa!