import java.util.Arrays; import java.util.Scanner; public class Main { public static int convert(String s) { if(s.equals("A")) return 1; if(s.equals("T")) return 10; if(s.equals("J")) return 11; if(s.equals("Q")) return 12; if(s.equals("K")) return 13; return Integer.parseInt(s); } public static String original(String s, int i) { if(i == 1) return s + "A"; if(i == 10) return s + "T"; if(i == 11) return s + "J"; if(i == 12) return s + "Q"; if(i == 13) return s + "K"; return s + 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].substring(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]) + " "); } }