#include <bits/stdc++.h>   using namespace std;   map<int, int> card;   void init() {     for (int i = 6, j = 1; i < 15; i++, j++) card.insert(make_pair(i, j));   }   int isCard(char num) {     int res = 0;     if (num >=  0  && num <=  9 )       res = num -  0 ;     else {       if (num ==  T )         res = 10;       else if (num ==  J )         res = 11;       else if (num ==  Q )         res = 12;       else if (num ==  K )         res = 13;       else         res = 14;     }     return res;   }   int main() {     char mn;     string s;     cin >> s;     mn = s[0];     cin >> s;     int id[2];     char ch[2];     id[0] = isCard(s[0]);     ch[0] = s[1];     cin >> s;     id[1] = isCard(s[0]);     ch[1] = s[1];     map<int, bool> mp;     mp.insert(make_pair(mn, true));     if (mp.find(ch[0]) != mp.end() && mp.find(ch[1]) == mp.end())       cout <<  YES ;     else if (mp.find(ch[0]) == mp.end() && mp.find(ch[1]) != mp.end())       cout <<  NO ;     else if (ch[0] != ch[1])       cout <<  NO ;     else if (id[0] > id[1])       cout <<  YES ;     else       cout <<  NO ;     return 0;   }   