#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; long long MOD = 1000000007; int main() { map X; X["A"] = "1"; X["T"] = "10"; X["J"] = "11"; X["Q"] = "12"; X["K"] = "13"; X["1"] = "A"; X["10"] = "T"; X["11"] = "J"; X["12"] = "Q"; X["13"] = "K"; int N; cin >> N; vector< vector > V(4); string S = "DCHS"; for ( int i = 0; i < N; i++ ) { string s; cin >> s; for ( int j = 0; j < 4; j++ ) { if ( S[j] == s[0] ) { s = s.substr(1,s.length()-1); if ( X[s].length() ) { s = X[s]; } V[j].push_back(stoi(s)); } } } for ( int i = 0; i < 4; i++ ) { sort( V[i].begin(), V[i].end() ); for ( int j = 0; j < V[i].size(); j++ ) { string s = to_string(V[i][j]); if ( X[s].length() ) { s = X[s]; } cout << S[i] << s; if ( i != 3 || j != V[i].size()-1 ) { cout << " "; } } } cout << endl; return 0; }