from collections import * def trump(n): if n == "A": return 1 elif n =="T": return 10 elif n == "J": return 11 elif n == "Q": return 12 elif n == "K": return 13 else: return int(n) N = int(input()) card = list(input().split()) D = defaultdict(list) DD = dict() for s in card: DD[trump(s[1])] = s[1] D[s[0]].append(trump(s[1])) ans = [] for a in sorted(D["D"]): ans.append("D" + DD[a]) for a in sorted(D["C"]): ans.append("C" + DD[a]) for a in sorted(D["H"]): ans.append("H" + DD[a]) for a in sorted(D["S"]): ans.append("S" + DD[a]) print(*ans)