#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define all(x) (x).begin(),(x).end() #define rep(i,m,n) for(int i = m;i < n;++i) #define pb push_back #define fore(i,a) for(auto &i:a) #define rrep(i,m,n) for(int i = m;i >= n;--i) #define INF INT_MAX/2 using namespace std; using ll = long long; using R = double; using Data = pair>; const ll MOD = 1e9 + 7; const ll inf = 1LL << 50; struct edge { ll from; ll to; ll cost; }; int check(char c) { if (2 <= c - '0' && c - '0' <= 9)return c - '0'; switch (c) { case 'A': return 1; case 'T': return 10; case 'J': return 11; case 'Q': return 12; case 'K': return 13; } } string conv(int i) { if (2 <= i && i <= 9)return to_string(i); switch (i) { case 1 : return "A"; case 10: return "T"; case 11 : return "J"; case 12 : return "Q"; case 13: return "K"; } } int main() { int n; cin >> n; vectorD; vectorC; vectorH; vectorS; rep(i, 0, n) { string s; cin >> s; char temp = s[0]; int num = check(s[1]); switch (temp) { case 'D': D.pb(num); break; case 'C': C.pb(num); break; case 'H': H.pb(num); break; case 'S': S.pb(num); break; } } sort(all(D)); sort(all(C)); sort(all(H)); sort(all(S)); fore(i, D) { cout << 'D' << conv(i) << " "; } fore(i, C) { cout << 'C' << conv(i) << " "; } fore(i, H) { cout << 'H' << conv(i) << " "; } fore(i, S) { cout << 'S' << conv(i) << " "; } cout << endl; return 0; }