#include using namespace std; int main() { int n; cin>>n; vector a(n); for(auto& e: a) cin>>e; map s; for(int i=0; i<13; ++i) s["23456789ATJQK"[i]]="23456789/;<=>"[i]; sort(begin(a), end(a), [&](auto x, auto y) { x[0]^=7, y[0]^=7; x[1]=s[x[1]], y[1]=s[y[1]]; return x