Pro.ID10219 TitleMagic Trick Title链接http://10.20.2.8/oj/exercise/problem?problem_id=10219 AC0 Submit0 Ratio- 时间&空间限制描述A magician invented a new card trick and presented it in the prestigious American Conference of Magicians (ACM). The trick was so nice it received the 'Best Magic Award' at the conference. The trick requires three participants: the magician himself, a spectator and an assistant. During the trick the spectator is asked to shuffle a deck of 52 cards and pick randomly 5 cards out of the deck. The five cards are given to the assistant (without the magician seeing the cards) who looks at them and shows four of the five cards one by one to the magician. After seeing the four cards the magician magically guesses the missing fifth card! The trick works because once the assistant has the five cards he can always choose four of them and use those to 'code' information about the fifth one. The code is based on an ordering of the cards. Cards are ordered first by their suits and then by their face value. We will use the following order:
Assume the spectator chose the cards JD, 8S, 7H, 8C, QH (Jack of Diamonds, 8 of Spades, 7 of Hearts, 8 of Clubs and Queen of Hearts). The strategy for the assistant is the following:
In this way, once the magician is shown the four cards one by one, he has enough information to "magically" guess the fifth one! Your job is to develop a program that, given the four cards shown by the assistant, informs the magician which is the hidden card. 输入The input contains several test cases. The first line in the input contains an integer N specifying the number of test cases (1 ≤ N ≤ 10000). Each test case is composed by one line, which contains the description of the four cards, separated by a space, in the order they were presented by the assistant. 输出Description A magician invented a new card trick and presented it in the prestigious American Conference of Magicians (ACM). The trick was so nice it received the 'Best Magic Award' at the conference. The trick requires three participants: the magician himself, a spectator and an assistant. During the trick the spectator is asked to shuffle a deck of 52 cards and pick randomly 5 cards out of the deck. The five cards are given to the assistant (without the magician seeing the cards) who looks at them and shows four of the five cards one by one to the magician. After seeing the four cards the magician magically guesses the missing fifth card! The trick works because once the assistant has the five cards he can always choose four of them and use those to 'code' information about the fifth one. The code is based on an ordering of the cards. Cards are ordered first by their suits and then by their face value. We will use the following order:
Assume the spectator chose the cards JD, 8S, 7H, 8C, QH (Jack of Diamonds, 8 of Spades, 7 of Hearts, 8 of Clubs and Queen of Hearts). The strategy for the assistant is the following:
In this way, once the magician is shown the four cards one by one, he has enough information to "magically" guess the fifth one! Your job is to develop a program that, given the four cards shown by the assistant, informs the magician which is the hidden card. Input The input contains several test cases. The first line in the input contains an integer N specifying the number of test cases (1 ≤ N ≤ 10000). Each test case is composed by one line, which contains the description of the four cards, separated by a space, in the order they were presented by the assistant. Output For each test case in the input your program must produce one line of output, containing the description of the hidden card. Sample Input 2 Sample Output QH Source 样例输入2 样例输出QH 作者 |