No-Fold Hold'em

Time limit1sMemory limit128 MB

Problem

Two players are playing Texas Hold'em. Your opponent never folds, no matter what cards appear, and always plays through the river, the fifth and final community card.

Each game is heads-up: only you and your opponent play. You are seated in position 1, and your opponent is seated in position 2. Each player has two private hole cards, and the first four of the five shared community cards are already face up.

The program knows your hole cards, your opponent's hole cards, and the four visible community cards. From the remaining deck, choose the river card or cards that maximize your result. If any river card makes you win, output all winning cards. If no card makes you win but at least one card makes you tie, output all tying cards. If every possible river card makes you lose, output a loss marker.

Input

The first line contains the number of data sets N, where 1 <= N <= 100.

Each data set consists of three lines.

  1. Your two hole cards
  2. Your opponent's two hole cards
  3. The four visible community cards

A card is written with two characters. The first character is its rank: one of A, 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K. The second character is its suit: spades S, diamonds D, hearts H, or clubs C. The ace of hearts is written as AH, and the nine of spades is written as 9S.

There are no spaces within a card line, and all input is valid.

Output

For each data set, output the list of river cards that gives you the best possible result.

If at least one card makes you win, output only the winning cards. If no card makes you win but at least one card makes you tie, output only the tying cards. If no card can make you win or tie, output LOSER.

Do not print a data set number or colon. Separate cards with one space. Print at most 15 cards on each line; if more cards remain, continue on the next line.

Cards must be sorted by suit order S, D, H, C. Within the same suit, sort by rank order 2, 3, 4, 5, 6, 7, 8, 9, T, J, Q, K, A.