# Five-round Show Hand

Time Limit: 4000/2000 MS (Java/Others)

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

## Description

The game of show hand is a card game. There are 52 cards and each card has a number and a suit. There are 13 different numbers called 2, 3, 4, 5, 6, 7, 8, 9, T (number 10), J (number 11), Q (number 12), K (number 13) and A (number 1 or 14), and there are 4 different suits called diamond (d), club (c), heart (h), and spade (s). A card can be represented as its number and its suit. For example, the card with number 10 and suit diamond is represented as “Td”, where “T” is for number 10 and “d” is for suit diamond. A hand is a combination of 5 cards.
There are 9 different kinds of hands, sorted from best to worst, listed below.
“Straight Flush”: 5 cards with consecutive numbers and the same suit. For example: Td Jd Qd Kd Ad.
“4 of a Kind”: 4 cards with the same number and an arbitrary single card. For example: 2d 2c 2h 2s 3d.
“Full House”: 3 cards with the same number and the remaining 2 cards have the same number. For example: 6d 6h 6s 7c 7s.
“Flush”: 5 cards with the same suit but not consecutive numbers. For example: 2h 3h Qh Kh Ah.
“Straight”: 5 cards with consecutive numbers but not the same suit. For example: As 2s 3s 4d 5d.
“3 of a Kind”: 3 cards with the same number and the remaining 2 cards have different numbers. For example: Td Tc Ts 9s As.
“2 Pairs”: 2 pairs of cards with the same number and the remaining card has a different number. For example: 3h 3s 6c 6h 4h.
“1 Pair”: 2 cards with the same number and the remaining 3 cards have different numbers. For example: 4d 4c 2c 5d Ac.
“High Card”: 5 cards with different, not consecutive numbers and not the same suits. For example: 2c 3d 8c 9h Ah.
There are 2 players in the game of five-round show hand. When the game starts, each player will get 25 cards from the dealer. Then, for each round, each player shows a hand by choosing 5 cards from the cards he gets, and two players compare the hands they showed. The player who shows a better kind of hand wins the game. If they show the same kind of hands, they discard the cards they have shown and proceed to the next round. There are at most 5 rounds in a game. If they show the same kind of hands in all of the 5 rounds, the game ends in a tie.
Both players play optimally. Your task is to find out the winner and the kind of hands he shows.

## Input

The first line is the number of test cases up to 600.
For each test case, there are two lines. The first line is the 25 cards player 1 gets, and the second line is the 25 cards player 2 gets. It is guaranteed that all the 50 cards are different.

## Output

For each test case, output a line containing the winner and the kind of hands he shows. If the game ends in a tie,output “Tie” and the kind of hands both player show.

## Sample Input

3
2d 2h 3d 3c 4d 4s 5d 6h 7d 7c 8d 8c 9d 9s
Td Tc Ts Th Jh Js Qd Qh Kc As Ad
2c 2s 3h 3s 4c 4h 5c 5h 5s 6d 6c 6s 7h 7s
8s 8h 9c 9h Jd Jc Qc Qs Kd Ac Ah
2s 3d 3c 3s 3h 4s 4h 5c 5s 6s 6h 7s 7h 8c
8s Td Th Js Jh Qs Qh Kc Kh Ad As
2d 2h 4d 4c 5d 5h 6d 6c 7d 7c 8d 8h 9d 9c
9s 9h Tc Ts Jd Jc Qd Kd Ks Ac Ah
2d 3d 4d 6d 7d 8d 9d Jd Qd Kd Ad 2c 3c 4c
6c 7c 8c 9c Jc Qc Kc Ac 5h 5s Th
2h 3h 4h 6h 7h 8h 9h Jh Qh Kh Ah 2s 3s 4s
6s 7s 8s 9s Js Qs Ks As 5d Td Tc

## Sample Output

Player 1, Straight Flush
Player 2, Straight Flush, 4 of a Kind,
Flush, Straight, 1 Pair
Tie, Flush, Flush, Flush, Flush, 2 Pairs

jiangzijing2015

## Source

2017ACM/ICPC亚洲区沈阳站-重现赛（感谢东北大学）