def cards(N, cs): D = [] C = [] H = [] S = [] for i in range(N): m = cs[i][0] n = cs[i][1] n = henkan(n) if m == 'D': D.append(n) elif m == 'C': C.append(n) elif m == 'H': H.append(n) elif m == 'S': S.append(n) D = sorted(D) C = sorted(C) H = sorted(H) S = sorted(S) ans = '' for d in D: ans += 'D' + str((henkan(d))) + ' ' for c in C: ans += 'C' + str(henkan(c)) + ' ' for h in H: ans += 'H' + str(henkan(h)) + ' ' for s in S: ans += 'S' + str(henkan(s)) + ' ' return ans def henkan(n): if n == 'A': a = 1 elif n == 'T': a = 10 elif n == 'J': a = 11 elif n == 'Q': a = 12 elif n == 'K': a = 13 elif n == 1: a = 'A' elif n == 10: a = 'T' elif n == 11: a = 'J' elif n == 12: a = 'Q' elif n == 13: a = 'K' else: a = int(n) return a def main(): N = int(input()) cs = list(map(str, input().split())) print(cards(N, cs)) if __name__ == '__main__': main()