Playing the fool
As you have learned, Peter loves to program. He recently decided to implement the popular card game "Fool". But Petit has much experience, he urgently needs your help.
As you know, "Fool" play a deck of 36 In Petya's program, each card appears as a string of two characters, where the first symbol indicates the rank ('6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A') cards, and the second character means a suit ('S', 'C', 'D', 'H'). The ranks are listed in ascending order of seniority.
Pete must solve the following problem: whether a player, having a set of N cards, recapture M cards, which under him made a move? In order to defend himself, a player must cover each of the cards, which under him make a move card from his deck. The card can cover either the highest card of the same suit, or trump suit card. If you react with itself is a trump card, it can cover only senior trump. One card can cover only one card.
Input
The first line of the input file contains a number of tests. Each test consists of three rows. On the first line of each test are two integers N and M (1 <= N <= 35, 1 <= M <= 4, M <= N), as well as a symbol of R, meaning the trump suit. On the second line of the test are listed N cards from a player's hand. On the next line of the test are listed M cards, which must be repelled. All the cards that you want to recapture, will have one rank.
Output
For each test should bring "YES" if you can fight off, or "NO", if you can not.