#include using namespace std; #define fst(t) std::get<0>(t) #define snd(t) std::get<1>(t) #define thd(t) std::get<2>(t) #define unless(p) if(!(p)) #define until(p) while(!(p)) using ll = long long; using P = std::tuple; const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1}; P toTuple(string card){ char suit = card[0]; int s; if(suit == 'D'){ s = 0; }else if(suit == 'C'){ s = 1; }else if(suit == 'H'){ s = 2; }else{ s = 3; } char number = card[1]; int n; if(number == 'A'){ n = 1; }else if(number == 'T'){ n = 10; }else if(number == 'J'){ n = 11; }else if(number == 'Q'){ n = 12; }else if(number == 'K'){ n = 13; }else{ n = number - '0'; } return std::make_tuple(s, n); } string cards[100]; int main(){ std::cin.tie(nullptr); std::ios::sync_with_stdio(false); int N; std::cin >> N; for(int i=0;i> cards[i]; } sort(cards, cards+N, [](const string& lhs, const string& rhs){ return toTuple(lhs) < toTuple(rhs); }); for(int i=0;i