A magician invented a new card trick and presented it at a prestigious magicians' conference, where it won the "Best Magic Award". The trick needs three people: the magician, a spectator, and an assistant.
The spectator shuffles a standard 52-card deck and picks 5 cards at random. These 5 cards are handed to the assistant, and the magician does not see them. The assistant looks at the cards and shows four of the five to the magician, one by one. After seeing those four cards, the magician names the hidden fifth card.
The trick works because, for any 5 cards, the assistant can always pick 4 of them and use the order in which they are shown to encode which card is hidden. The encoding relies on a fixed total order on the cards: first by suit, then by face value.
Each card is written as two characters: its face value followed by its suit letter, for example QH (Queen of Hearts) or 1C (Ace of Clubs).
As an example, suppose the spectator chose JD, 8S, 7H, 8C, QH. The assistant's strategy is:
The magician adds this number to $y$'s face value, wrapping around after $K$ back to $1$, to obtain the hidden card's face value; the hidden card's suit is the same as $y$'s.
Given the four cards shown by the assistant, in the order shown (so the first card is $y$), write a program that determines the hidden card.
The first line contains an integer $N$, the number of test cases ($1 \le N \le 10000$). Each of the next $N$ lines contains one test case: the four cards, separated by single spaces, in the order the assistant presented them (so the first card is $y$).
For each test case, print one line containing the hidden card.