import java.util.Arrays; import java.util.Scanner; public class Main { public static int convert(char c) { if(c == 'A') return 1; if(c == 'T') return 10; if(c == 'J') return 11; if(c == 'Q') return 12; if(c == 'K') return 13; return (int)(c - '0'); } public static String original(char c, int i) { if(i == 1) return c + "A"; if(i == 10) return c + "T"; if(i == 11) return c + "J"; if(i == 12) return c + "Q"; if(i == 13) return c + "K"; return c + String.valueOf(i); } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = Integer.parseInt(sc.next()); int D = 0, C = 0, H = 0, S = 0; String[] t = new String[n]; for (int i = 0; i < n; i++){ t[i] = sc.next(); if(t[i].charAt(0) == 'D') D++; if(t[i].charAt(0) == 'C') C++; if(t[i].charAt(0) == 'H') H++; if(t[i].charAt(0) == 'S') S++; } int[] d = new int[D];D = 0; int[] c = new int[C];C = 0; int[] h = new int[H];H = 0; int[] s = new int[S];S = 0; for (int i = 0; i < n; i++){ int v = convert(t[i].charAt(1)); if(t[i].charAt(0) == 'D') d[D++] = v; if(t[i].charAt(0) == 'C') c[C++] = v; if(t[i].charAt(0) == 'H') h[H++] = v; if(t[i].charAt(0) == 'S') s[S++] = v; } Arrays.sort(d); Arrays.sort(c); Arrays.sort(h); Arrays.sort(s); for (int i = 0; i < D; i++) System.out.print(original('D', d[i]) + " "); for (int i = 0; i < C; i++) System.out.print(original('C', c[i]) + " "); for (int i = 0; i < H; i++) System.out.print(original('H', h[i]) + " "); for (int i = 0; i < S; i++) System.out.print(original('S', s[i]) + " "); } }