#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define RALL(x) (x).rbegin(),(x).rend() #define ALL(x) (x).begin(),(x).end() #define repp(i,n) for(int (i)=1;(i)<=(n);(i)++) #define rep(i,n) for(int (i)=0;(i)<(n);(i)++) #define rev(i,n) for(int (i)=(n-1);(i)>=0;(i)--) #define clr(a) memset((a), 0 ,sizeof(a)) typedef pair P; typedef vector > pii; typedef map mdi; int main(){ vector vc,vc2,vc3,vc4; bool ok=false,ok2=false,ok3=false,ok4=false; int n,x=0; string s; cin >> n; for(int i=0;i> s; if(s[0]=='D'){ if(s[1]=='A') vc.push_back(1); else if(s[1]=='T') vc.push_back(10); else if(s[1]=='J') vc.push_back(11); else if(s[1]=='Q') vc.push_back(12); else if(s[1]=='K') vc.push_back(13); else vc.push_back(s[1]-'0'); } else if(s[0]=='C'){ if(s[1]=='A') vc2.push_back(1); else if(s[1]=='T') vc2.push_back(10); else if(s[1]=='J') vc2.push_back(11); else if(s[1]=='Q') vc2.push_back(12); else if(s[1]=='K') vc2.push_back(13); else vc2.push_back(s[1]-'0'); } else if(s[0]=='H'){ if(s[1]=='A') vc3.push_back(1); else if(s[1]=='T') vc3.push_back(10); else if(s[1]=='J') vc3.push_back(11); else if(s[1]=='Q') vc3.push_back(12); else if(s[1]=='K') vc3.push_back(13); else vc3.push_back(s[1]-'0'); } else if(s[0]=='S'){ if(s[1]=='A') vc4.push_back(1); else if(s[1]=='T') vc4.push_back(10); else if(s[1]=='J') vc4.push_back(11); else if(s[1]=='Q') vc4.push_back(12); else if(s[1]=='K') vc4.push_back(13); else vc4.push_back(s[1]-'0'); } sort(ALL(vc)); sort(ALL(vc2)); sort(ALL(vc3)); sort(ALL(vc4)); } for(int i=0;i0) cout << " "; x=1; ok=true; cout << "D"; if(vc[i]==1) cout << "A"; else if(vc[i]==10) cout << "T"; else if(vc[i]==11) cout << "J"; else if(vc[i]==12) cout << "Q"; else if(vc[i]==13) cout << "K"; else cout << vc[i]; } for(int i=0;i0) cout << " "; cout << "C"; if(vc2[i]==1) cout << "A"; else if(vc2[i]==10) cout << "T"; else if(vc2[i]==11) cout << "J"; else if(vc2[i]==12) cout << "Q"; else if(vc2[i]==13) cout << "K"; else cout << vc2[i]; } for(int i=0;i0) cout << " "; cout << "H"; if(vc3[i]==1) cout << "A"; else if(vc3[i]==10) cout << "T"; else if(vc3[i]==11) cout << "J"; else if(vc3[i]==12) cout << "Q"; else if(vc3[i]==13) cout << "K"; else cout << vc3[i]; } for(int i=0;i0) cout << " "; cout << "S"; if(vc4[i]==1) cout << "A"; else if(vc4[i]==10) cout << "T"; else if(vc4[i]==11) cout << "J"; else if(vc4[i]==12) cout << "Q"; else if(vc4[i]==13) cout << "K"; else cout << vc4[i]; } cout << endl; return 0; }