#include #include #include #include using namespace std; using P = pair; int main(){ int n; cin >> n; vector m(n); for(int i = 0; i < n; i++) cin >> m[i]; vector

order(n); const string mark = "DCHS"; const string number = "A23456789TJQK"; for(int i = 0; i < n; i++){ order[i].second = i; for(int j = 0; j < 4; j++){ if(m[i][0] == mark[j]){ order[i].first = j*100; } } for(int j = 0; j < 13; j++){ if(m[i][1] == number[j]){ order[i].first += j; } } } sort(order.begin(), order.end()); for(int i = 0; i < n; i++){ if(i != 0) cout << " "; cout << m[order[i].second]; } cout << endl; return 0; }