# -*- coding: utf-8 -*- def ch(card): card1 = card.replace("A", "1") card2 = card1.replace("T", "10") card3 = card2.replace("J", "11") card4 = card3.replace("Q", "12") card5 = card4.replace("K", "13") if "D" in card5: card5 = card5.lstrip("D") card5 = card5.rjust(2, "0") card6 = int(card5) + 100 return card6 elif "C" in card5: card5 = card5.lstrip("C") card5 = card5.rjust(2, "0") card6 = int(card5) + 200 return card6 elif "H" in card5: card5 = card5.lstrip("H") card5 = card5.rjust(2, "0") card6 = int(card5) + 300 return card6 else: card5 = card5.lstrip("S") card5 = card5.rjust(2, "0") card6 = int(card5) + 400 return card6 def rech(card): if 100 < card < 200: Mk = "D" card -= 100 elif 200 < card < 300: Mk = "C" card -= 200 elif 300 < card < 400: Mk = "H" card -= 300 elif 400 < card: Mk = "S" card -= 400 if card == 1: No = "A" elif card == 10: No = "T" elif card == 11: No = "J" elif card == 12: No = "Q" elif card == 13: No = "K" else: No = card return Mk + str(No) N = input() inp = raw_input().split() inp = map(ch, inp) inp.sort() inp = map(rech, inp) out = "" for i in range(0, N): out += inp[i] if i != N-1: out += " " print out