## Algorithm

A. Card Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

There is a card game called "Durak", which means "Fool" in Russian. The game is quite popular in the countries that used to form USSR. The problem does not state all the game's rules explicitly — you can find them later yourselves if you want.

To play durak you need a pack of 36 cards. Each card has a suit ("S", "H", "D" and "C") and a rank (in the increasing order "6", "7", "8", "9", "T", "J", "Q", "K" and "A"). At the beginning of the game one suit is arbitrarily chosen as trump.

The players move like that: one player puts one or several of his cards on the table and the other one should beat each of them with his cards.

A card beats another one if both cards have similar suits and the first card has a higher rank then the second one. Besides, a trump card can beat any non-trump card whatever the cards’ ranks are. In all other cases you can not beat the second card with the first one.

You are given the trump suit and two different cards. Determine whether the first one beats the second one or not.

Input

The first line contains the tramp suit. It is "S", "H", "D" or "C".

The second line contains the description of the two different cards. Each card is described by one word consisting of two symbols. The first symbol stands for the rank ("6", "7", "8", "9", "T", "J", "Q", "K" and "A"), and the second one stands for the suit ("S", "H", "D" and "C").

Output

Print "YES" (without the quotes) if the first cards beats the second one. Otherwise, print "NO" (also without the quotes).

Examples
input
Copy
`HQH 9S`
output
Copy
`YES`
input
Copy
`S8D 6D`
output
Copy
`YES`
input
Copy
`C7H AS`
output
Copy
`NO`

## Code Examples

### #1 Code Example with C++ Programming

```Code - C++ Programming```

``````#include <cstdio>
#include <iostream>
#include <map>

int main(){

char trump; scanf("%c\n", &trump);
std::string input; getline(std::cin, input);
std::string output("NO");

std::map<char, int> value;
value.insert(std::pair<char, int>('6', 6));
value.insert(std::pair<char, int>('7', 7));
value.insert(std::pair<char, int>('8', 8));
value.insert(std::pair<char, int>('9', 9));
value.insert(std::pair<char, int>('T', 10));
value.insert(std::pair<char, int>('J', 11));
value.insert(std::pair<char, int>('Q', 12));
value.insert(std::pair<char, int>('K', 13));
value.insert(std::pair<char, int>('A', 14));

if(input[1] == trump && input[4] != trump){output = "YES";}
else if(input[1] == input[4] && value[input[0]] > value[input[3]]){output = "YES";}

std::cout << output << std::endl;
return 0;
}``````
Copy The Code &

Input

cmd
H
QH 9S

Output

cmd
YES