Rubik's Cube

No attempts yetTime limit1sMemory limit128 MB

Problem

The Rubik's Cube is a puzzle made by Ernő Rubik, a sculptor and professor of architecture. Twenty-seven small cubes form one large cube, and every square on the outside is painted in one of six fixed colors. Each layer turns in place, and the goal is to bring the scattered colors back to a single color per face.

B, a first-year university student, was reading a cube manual when this question came to him. Given the outside appearance of two cubes, how do you tell whether the two are really the same cube seen from different directions? Help B solve it.

An appearance is written down like this. The six faces are listed in the order below.

The nine squares of one face are listed in the order below.

So the cube drawn in the net below is written as the six lines printed under the picture.

Given the outside appearance of two cubes, write a program that decides whether the two appearances are the same cube seen from different directions.

Input

Input is read from standard input. The first line has the number of test cases T (1 ≤ T ≤ 20). The test cases follow one after another.

Each test case gives the appearance of two cubes. One appearance is 54 numbers: the six faces in the order fixed above, and inside one face the nine squares in the order fixed above. A color is a number from 0 to 5, and each number appears exactly nine times in one appearance. Every number in the input is separated by whitespace.

Output

Write to standard output. Print one result per test case, one per line. Print Y if the two given appearances are the same cube seen from different directions, and N otherwise.