11879 - Four of a kind   

Description

In this problem, you are to write a program to check whether a set of five cards forms a "four of a kind". The input contains T sets of 5 cards to verify the correctness of your program.

Four of a kind, also known as quads, is a poker hand containing four cards of the same rank and one card of another rank (the kicker), such as 9♣ 9♠ 9♦ 9♥ J♥ ("four of a kind, nines"). It ranks below a straight flush and above a full house.

There are 624 possible four of a kind hands and 156 distinct ranks of four of a kind when using a standard 52-card deck. Each four of a kind is ranked first by the rank of its quadruplet, and then by the rank of its kicker. For example, K♠ K♥ K♣ K♦ 3♥ ranks higher than 7♥ 7♦ 7♠ 7♣ Q♥, which ranks higher than 7♥ 7♦ 7♠ 7♣ 10♠. Four of a kind hands that differ by suit alone, such as 4♣ 4♠ 4♦ 4♥ 9♣ and 4♣ 4♠ 4♦ 4♥ 9♦, are of equal rank.

Input

The first line contains an integer T, representing the number of sets.

The next T lines contain 5 cards in each given set, separated by whitespaces.

The cards would range from : {A, 2, 3, 4, 5, 6, 7, 8 ,9 ,10, J, Q, K}.

(In this problem, you don't need to consider the suit of each card. No card set of 5 cards contains 5 identical cards.)

  • 1 ≤ | T | ≤ 10000

Output

For each set of cards, please print 'YES' if the set is a "four of a kind"; otherwise, please print 'NO'.

Remember to print '\n' after each line.

Sample Input  Download

Sample Output  Download

Tags




Discuss