z = input()
d = {}
while 1:
    x = raw_input().split()
    print x
    if x[0] == '0':
        break
    else:
        d[x[0]] = d.get(x[0],[]) + [x[1]]

L = ['S','H','C','D']

for i in L:
    for j in sorted(d[i]):
        print i + " " + j