Magician Hyunwoo

Time limit1sMemory limit128 MB

Problem

Magician Hyunwoo is entering a card magic contest. Normally, his assistant looks at the 5 cards chosen by the audience, returns 1 of them to the audience, and hands the other 4 cards to Hyunwoo in a carefully chosen order. Because the assistant suddenly cannot participate, Hyunwoo built a robot to do that job.

The trick uses a standard 52-card deck. The deck order is determined first by rank, and cards with the same rank are ordered by suit: C, D, H, S. Thus the order is AC, AD, AH, AS, 2C, 2D, ..., KH, KS.

Hyunwoo identifies the card returned to the audience from the 4 cards handed to him by the robot. Let the first of those 4 cards be the base card. He restores the hidden card by the following rules.

  1. Remember the suit and rank of the base card.
  2. Among the remaining three cards, find the smallest card and add its position number to the base card's rank.
  3. If the two largest cards among those three are not in the deck order described above, add 3 more.
  4. If the computed rank goes past K, subtract 13 so that the ranks continue again from A. The card with this rank and the base card's suit is the card returned to the audience.

Given the 5 cards chosen by the audience, find an order the robot can output so that Hyunwoo can determine the hidden card by these rules.

Input

The first line contains the number of test cases, T. Each test case consists of one line containing 5 cards separated by spaces. Each card is written as a rank (A, 2 through 10, J, Q, K) followed by a suit (C, D, H, S).

Output

For each test case, print one line containing 5 cards. The first card is the card returned to the audience, and the next 4 cards are the cards handed to Hyunwoo in order.