# cube cube cube

Time Limit: 6000/3000 MS (Java/Others)

Memory Limit: 327680/327680 K (Java/Others)

## 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)

## Sample Input

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

## Sample Output

YES

liuyiding

## Source

2017 ACM/ICPC Asia Regional Shenyang Online