Problems
Playing the fool
Playing the fool
As you have learned, Peter loves to program. He recently decided to implement the popular card game "\textbf{Fool}". But Petit has much experience, he urgently needs your help.
As you know, "\textbf{Fool}" play a deck of \textbf{36} In Petya's program, each card appears as a string of two characters, where the first symbol indicates the rank ('\textbf{6}', '\textbf{7}', '\textbf{8}', '\textbf{9}', '\textbf{T}', '\textbf{J}', '\textbf{Q}', '\textbf{K}', '\textbf{A}') cards, and the second character means a suit ('\textbf{S}', '\textbf{C}', '\textbf{D}', '\textbf{H}'). The ranks are listed in ascending order of seniority.
Pete must solve the following problem: whether a player, having a set of \textbf{N} cards, recapture \textbf{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.
\InputFile
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 \textbf{N} and \textbf{M} (\textbf{1} <= \textbf{N} <= \textbf{35}, \textbf{1} <= \textbf{M} <= \textbf{4}, \textbf{M} <= \textbf{N}), as well as a symbol of \textbf{R}, meaning the trump suit. On the second line of the test are listed \textbf{N} cards from a player's hand. On the next line of the test are listed \textbf{M} cards, which must be repelled. All the cards that you want to recapture, will have one rank.
\OutputFile
For each test should bring "\textbf{YES}" if you can fight off, or "\textbf{NO}", if you can not.
Input example #1
2 6 2 C KD KC AD 7C AH 9C 6D 6C 4 1 D 9S KC AH 7D 8D
Output example #1
YES NO