
You are a secret agent for the Eternally Indebted External Intelligence Office (EIEIO) of the country of Nomoneo. Headquarters has hidden your one-time pad for encrypted communication inside a Rubik's Cube.
(In case you are not familiar with the puzzle: a Rubik's Cube is a cube whose six faces are each divided into three rows and three columns, giving nine small squares per face. Any face can be turned clockwise or counterclockwise; turning a face also carries the three nearest squares of each neighboring face onto a new face. When the cube is solved, every face shows a single color. The relative positions of the six center-square colors can never change.)
The cube is given already scrambled. To send your message, you apply a given sequence of face rotations to it.
The picture above shows how the six faces are connected and how each face is oriented for input and output. Read it as a cube unfolded with the printed side facing outward. Each face is named by the color of its center square: White (W), Orange (O), Red (R), Blue (B), Green (G), and Yellow (Y). The corner marked with a dot is that face's top-left corner, and it is the reference point for input and output.
The net is laid out as follows (each cell is one face; the dot marks that face's top-left corner):
W O
R
B
G Y
The first line contains an integer $T$ ($1 \le T \le 10000$), the number of test cases.
Each test case consists of four lines. The first three lines give the initial state of the cube. Each of these lines contains 18 letters separated by single spaces, with no trailing space. Every letter is one of 'W', 'O', 'R', 'B', 'G', or 'Y' and denotes the color of one square. The six faces appear from left to right in the order White, Orange, Red, Blue, Green, Yellow, with three columns per face; so the first three letters of each line describe the White face, the next three the Orange face, and so on. The three lines correspond to the top, middle, and bottom rows of every face.
The fourth line lists the rotations to apply, as a string of letters from 'W', 'O', 'R', 'B', 'G', 'Y'. Each letter selects the face whose center has that color and turns it 90 degrees clockwise as seen when looking straight at that face. There are between 1 and 1000 rotations, applied from left to right.
For each test case, print the state of the cube after all rotations, using the same format as the input: three lines of 18 color letters separated by single spaces, with no trailing space, and the faces in the same left-to-right order White, Orange, Red, Blue, Green, Yellow. After each test case, print a line containing exactly 35 '=' characters.