#define _CRT_SECURE_NO_WARNINGS //#define _GLIBCXX_DEBUG #include using namespace std; typedef long long ll; //#define int ll //#define endl "\n" typedef vector vi; typedef vector vvi; typedef pair pii; #define all(c) (c).begin(), (c).end() #define loop(i,a,b) for(ll i=a; i ostream & operator<<(ostream & os, vector const &); template typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple const &){} template typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple const & t){ os << (n==0?"":" ") << get(t); _ot(os, t); } template ostream & operator<<(ostream & os, tuple const & t){ _ot<0>(os, t); return os; } template ostream & operator<<(ostream & os, pair const & p){ return os << "(" << p.first << ", " << p.second << ") "; } template ostream & operator<<(ostream & os, vector const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; } template inline bool chmax(T & x, T const & y){ return x inline bool chmin(T & x, T const & y){ return x>y ? x=y,true : false; } #ifdef DEBUG #define dump(...) (cerr<<#__VA_ARGS__<<" = "<> n){ vector v(n); rep(i,n) cin >> v[i]; sort(all(v), [&](string const& a, string const& b){ map ord_suite { {'D',1},{'C',2},{'H',3},{'S',4} }; map ord_rank; for(int i=2;i<=9;i++) ord_rank[i+'0'] = i; ord_rank['A'] = 1; ord_rank['T'] = 10; ord_rank['J'] = 11; ord_rank['Q'] = 12; ord_rank['K'] = 13; return a[0] != b[0] ? ord_suite[a[0]] < ord_suite[b[0]] : ord_rank[a[1]] < ord_rank[b[1]]; }); rep(i,n){ cout << v[i] << (i+1==n ? "\n" : " "); } } }