#include #define rep(i,n) for(int i=0;i<(int)(n);i++) using namespace std; using ll = long long ; using P = pair ; using pll = pair; constexpr int INF = 1e9; constexpr long long LINF = 1e17; constexpr int MOD = 1000000007; constexpr double PI = 3.14159265358979323846; map mp = {{'A',1},{'2',2},{'3',3},{'4',4},{'5',5},{'6',6},{'7',7},{'8',8},{'9',9},{'T',10},{'J',11},{'Q',12},{'K',13}}; vector inv = {'0','A','2','3','4','5','6','7','8','9','T','J','Q','K'}; vector a = {'D','C','H','S'}; bool f(char l,char r){ return mp[l] < mp[r]; } int main(){ int n; cin >> n; vector> ans(4,vector()); rep(i,n){ string s; cin >> s; rep(i,4){ if(s[0]==a[i]) ans[i].push_back(s[1]); } } rep(i,4) sort(ans[i].begin(),ans[i].end(),f); rep(i,4){ rep(j,ans[i].size()) cout << a[i] << ans[i][j] << " "; } cout << endl; return 0; }