Contest02-3 Cube

Time Limit: 1000 ms Memory Limit: 65536 KiB

Problem Description

Klins has a dramatic toy made of 27 blocks. The toy is illustrated in Figure 1(a) below:

The toy is made of 17 groups. Each group is composed of 3 or 2 blocks. Each junction between two consecutive groups can rotate 360 degrees. So if Klins is smart enough, he can use the toy to form a 3*3*3 cube(See Figure 1(c)).

In Figure 1(a) above, the first group has 3 blocks, the second group has 2 blocks, and the third has 3 ones, and so on. As the blocks in each group are connected by a bungee, they can never move out of the group whatever possible rotation is performed(See Figure 1(b)).

But not all kinds of such toys that are made up of 27 blocks are possible to form a cube. Klins wants to know whether the given toy can form a cube or not.

Input

The input contains multiple cases. The first line of input is the number of test cases(<=1500). For each case, there are 17 integers in a line, each of which is either 3 or 2, denoting the number of blocks in each group. These numbers are given in consective order, i.e. any two consecutive groups are assumed to be connected with each other.

Output

For each test case, print one line of "yes" if a cube of 3*3*3 can be formed using the given toy, otherwise print "no".

Sample Input

2
3 2 3 2 3 2 3 2 3 2 3 2 3 2 3 2 3
3 3 3 3 2 2 2 3 3 2 2 3 2 3 2 2 3

Sample Output

yes
yes

ZSCPC9