#include using namespace std; using Int = long long; //INSERT ABOVE HERE signed main(){ Int n; cin>>n; vector s(n); for(Int i=0;i>s[i]; auto calc= [](string s){ Int res=0; if(s[0]=='D') res+=1000000*1; if(s[0]=='C') res+=1000000*2; if(s[0]=='H') res+=1000000*3; if(s[0]=='S') res+=1000000*4; if(s[1]=='A') res+=1; else if(s[1]=='T') res+=10; else if(s[1]=='J') res+=11; else if(s[1]=='Q') res+=12; else if(s[1]=='K') res+=13; else res+=s[1]-'0'; return res; }; sort(s.begin(),s.end(),[&](string a,string b){return calc(a)