#include using namespace std; int main() { int n; cin >> n; vector > card; for (int i=0; i> s; if (s[0] == 'D') t += 'A'; if (s[0] == 'C') t += 'B'; if (s[0] == 'H') t += 'C'; if (s[0] == 'S') t += 'D'; if ('2' <= s[1] && s[1] <= '9') t += 'A' + (s[1]-'1'); if (s[1] == 'A') t += 'A'; if (s[1] == 'T') t += 'J'; if (s[1] == 'J') t += 'K'; if (s[1] == 'Q') t += 'L'; if (s[1] == 'K') t += 'M'; card.push_back(make_pair(t, s)); } sort(card.begin(), card.end()); for (int i=0; i