#include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n) for(int i=0;i=0;i--) #define DREP(i,n) for(int i=n;i>0;i--) #define Rep(i,m,n) for(int i=m;i vi; typedef vector> vvi; typedef pair pdd; typedef pair pii; const double pi=acos(-1.0); double rad(double t){return t*pi/180.0;} double deg(double d){return d*180.0/pi;} templateT GCD(T x,T y){return y?GCD(y,x%y):x;} templateT LCM(T x,T y){return x/GCD(x,y)*y;} templateostream& operator<<(ostream& os,const set& s){os<<"{";for(auto itr=s.begin();s.end()!=itr;++itr){if(itr!=s.begin())os<<',';os<<*itr;}os<<"}";return os;} templateostream& operator<<(ostream& os,const pair& p){os<<'('< vs; int N; cin>> N; rep(i,N){ string temp; cin >> temp; if(temp[0]=='D')temp[0]='A'; char c=temp[1]; switch(c){ case 'A': temp[1] = '0'+1;break; case 'T': temp[1] = '0'+10;break; case 'J': temp[1] = '0'+11;break; case 'Q': temp[1] = '0'+12;break; case 'K': temp[1] = '0'+13;break; } vs.pb(temp); } sort(all(vs)); rep(i,N){ if(i)cout << ' ' ; if(vs[i][0]=='A')vs[i][0]='D'; cout << vs[i][0] ; switch(vs[i][1]){ case '0'+1: cout << 'A';break; case '0'+10: cout << 'T';break; case '0'+11: cout << 'J';break; case '0'+12: cout << 'Q';break; case '0'+13: cout << 'K';break; default: cout << vs[i][1]; } } cout << endl; return 0; }