#include <bits/stdc++.h>   using namespace std;   int main() {     char a;     cin >> a;     string str1, str2;     cin >> str1 >> str2;     int b1, b2;     switch (str1[0]) {       case  T :         b1 = 10;         break;       case  J :         b1 = 11;         break;       case  Q :         b1 = 12;         break;       case  K :         b1 = 13;         break;       case  A :         b1 = 14;         break;       default:         b1 = str1[0] -  0 ;     }     switch (str2[0]) {       case  T :         b2 = 10;         break;       case  J :         b2 = 11;         break;       case  Q :         b2 = 12;         break;       case  K :         b2 = 13;         break;       case  A :         b2 = 14;         break;       default:         b2 = str2[0] -  0 ;     }     if (str1[1] == a)       if (str2[1] != str1[1]) {         cout <<  YES ;       } else {         if (b1 > b2) {           cout <<  YES ;         } else           cout <<  NO ;       }     else {       if (str2[1] == str1[1]) {         if (b1 > b2) {           cout <<  YES ;         } else           cout <<  NO ;       } else {         cout <<  NO ;       };     }     return 0;   }   