Playing the fool#501

Playing the fool

1 second
64 megabytes
Medium

As you already know, Peter loves programming. Recently, he decided to implement the popular card game "Fool". However, Peter does not have much experience yet and urgently needs your help.

As is known, "Fool" is played with a deck of cards. In Peter's program, each card is represented as a string of two characters: the first character is the rank ('6', '7', '8', '9', 'T', 'J', 'Q', 'K', 'A'), and the second character is the suit ('S', 'C', 'D', 'H'). The ranks are listed in ascending order of strength.

Peter faces the following task: can a player with cards in their hand beat off cards played against them? To defend, the player must cover each attacking card with a card from their hand. A card can be covered either by a higher card of the same suit or by any trump card. If the card to be covered is itself a trump, it can only be covered by a higher trump. One card can cover only one attacking card.

Input

The first line of the input file contains the number of tests. Each test consists of three lines. The first line of each test contains two integers and (1 \leq N \leq 35, 1 \leq M \leq 4, M \leq N), and a character representing the trump suit. The second line of the test contains the cards in the player's hand. The third line contains the cards that need to be beaten off. All cards that need to be beaten off have the same rank.

Output

For each test, output "YES" if it is possible to beat off, or "NO" otherwise.

Examples

Example 1

Loading
Loading