In a parallel universe, HRY is a gambling expert. This time, he is playing Fight the Landlord with the pumpkin, 10256 at the table!
As everyone knows, when playing Fight the Landlord, HRY is sure to try to be the landlord. This time he also got the wish to be the landlord!
Whoa! He's got good luck!
After a few rounds, HRY has already played some cards (or maybe zero cards). Now it's HRY's turn again. He wants to know if he can play all the remaining cards he has in this round.
Rules of Fight the Landlord:
The deck consists of 54 cards. From small to large, the points are 3 < 4 < 5 < 6 < 7 < 8 < 9 < 10 < J < Q < K < A < 2 < W1 < W2. For W1 and W2 there is only 1 card for each and for other points they have 4 cards for each. At the beginning, the landlord has 20 cards, and the two civilians have 17 cards. The landlord plays first.
The types of card that can be played in a round:
Single: Any single card can be used as a Single, such as J or W2.
Pair: Any two cards with the same point, such as 3 3 or Q Q. But W1 W2 is not a Pair.
Triple: Any three cards with the same point, such as 9 9 9.
Triple plus a Single: A "Triple" and a "Single". The points of the "Triple" and the "Single" must be different, such as 10 10 10 9.
Triple plus a Pair: A "Triple" and a "Pair", such as 7 7 7 K K.
Single Straight: Five or more consecutive "Singles", excluding 2, W1, W2. Such as 3 4 5 6 7 8 or 6 7 8 9 10 J Q K A.
Pair Straight: Three or more consecutive "Pairs", excluding 2, W1, W2. Such as 3 3 4 4 5 5 or 5 5 6 6 7 7 8 8.
Triple Straight: Two or more consecutive "Triples", excluding 2, W1, W2. Such as 4 4 4 5 5 5 or J J J Q Q Q K K K.
Airplane No. 1: Two or more consecutive "Triple plus a Single", excluding "Triple" 2 2 2. For example, 3 3 3 9 4 4 4 2 or K K K 10 A A A 10 are valid, but A A A 3 2 2 2 4 is not valid. "Consecutive" here means that the point of the "Triple" in each "Triple plus a Single" is consecutive.
Airplane No. 2: Two or more consecutive "Triple plus a Pair", excluding "Triple" 2 2 2. For example, J J J 2 2 Q Q Q 8 8 or 7 7 7 3 3 8 8 8 3 3 are valid, but A A A 3 3 2 2 2 K K is not vaild. "Consecutive" here means that the point of the "Triple" in each "Triple plus a Pair" is consecutive.
Bomb: Any four cards with the same point, such as 3 3 3 3 or K K K K.
Rocket: The combination of W1 and W2.
Quartet plus two Singles: One
Bomb" and two "Singles" (two Singles can be the same), such as 4 4 4 4 5 A or 4 4 4 4 K K.
Note: For "Triple plus a Single" and "Quartet plus two Singles", the Single can be W1 or W2.
If the above rules are different from the rules you have seen, please follow the above rules.
输入描述:
The first line of input contains an integer T, indicating the number of test case.
For each test case :
The first line contains a positive integer n, indicating the number of cards HRY still has in his hand.
The second line contains n strings separated by spaces, indicating the cards HRY still has.
It is guaranteed that the input is valid.
输出描述:
For each test case output a line. If he can play all of his cards in this round, output "Ye5", else output "N0"(without quotes).
示例1
输入
复制
11
12
3 4 5 6 7 8 9 10 J Q K A
13
3 4 5 6 7 8 9 10 J Q K A 2
7
6 6 7 7 8 8 8
10
3 3 3 4 4 4 5 5 5 5
8
9 9 9 10 10 10 W1 W2
12
6 6 6 7 7 7 8 8 8 7 8 9
5
4 4 4 4 5
6
2 2 2 2 3 A
7
4 4 4 5 5 5 W2
6
K K A A 2 2
5
3 3 3 W1 W2
输出
复制
Ye5
N0
N0
Ye5
Ye5
Ye5
N0
Ye5
N0
N0
N0