The Accelerated Card Union (ACU) prides itself on quick and accurate decisions about winning hands in ACU Poker. To insure both quick and correct evaluations, ACU's dealers are always practicing poker.
Poker is played with a regular deck of 52 cards including one of each of four suits (in order: s, h, d, and c) and thirteen ranks (in order: A, K, Q, J, T, 9, 8, 7, 6, 5, 4, 3, 2). Each 5-card hand can be described by the following ordered list; better hands are listed first.
Ties are broken by considering the highest card (rank, then suit) from amoung the cards described in the definitions above. In a Full House, consider the Three of a Kind before considering the Pair. In a Straight in which A is played low, consider A less than 2.
Write a program to compare two poker hands and determine the winning hand.
InputThe first line of input consists of a single integer on a line by itself specifying the number of data sets to consider. The input for each data set is on a single line consisting of ten pairs of letters separated by a single space. Each pair consists of the rank and suit of a card, respectively. The first five cards make up Abe's hand; the last five make up Bob's hand. |
OutputEach data set should produce one line of output indicating the name of the winner and the value of his poker hand as shown below. | |
Sample input:
3 Ks As Js Ts Qs 2s 3h 4c 5d 2d 2s 3d 4s 3s 4h Td 9d 8d Kd 4c 3c 4c 5c 7c 6c 3s 7s 6s 5s 4s |
Sample output:
Abe wins with a Royal Flush Bob wins with a High Card Bob wins with a Straight Flush |