#P6202. cube cube cube
cube cube cube
Problem Description
Rubick has a strange cube. Can you restore Rubik's cube in 3 steps (including 3)?
Rubik's cube is shown in the following picture:

The plane expansion of the Rubik's cube is shown in the following figure, each number represents the color corresponding to each cube.

The following picture explains how to rotate this strange cube. If you still feel confused, you can refer to
http://www.bilibili.com/video/av8452301/?from=search&seid=11750270100959783079 .

Input
The first line contains an integer $T$ ($T \leq 10$), the number of test cases.
Each test case consists of 72 integers which correspond to the colors of each location of the Rubik's Cube. Each number represents one color, it's guaranteed that there are exactly 8 colors and each color appears 9 times.
Output
For each test case, if you can restore the Rubik's cube in 3 steps, output "YES", else output "NO". (both without quote)
1
1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2
3 3 3 3 3 3 3 3 3
4 4 4 4 4 4 4 4 4
5 5 5 5 5 5 5 5 5
6 6 6 6 6 6 6 6 6
7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8
YES