Problem:

Finding Missing Cards

  Taro is going to play a card game. However, now he has only n cards, even though there should be 52 cards (he has no Jokers).

The 52 cards include 13 ranks of each of the four suits: spade, heart, club and diamond.

Input

  In the first line, the number of cards n (n ≤ 52) is given.

  In the following n lines, data of the n cards are given. Each card is given by a pair of a character and an integer which represent its suit and rank respectively. A suit is represented by 'S', 'H', 'C' and 'D' for spades, hearts, clubs and diamonds respectively. A rank is represented by an integer from 1 to 13.

Output

  Print the missing cards. The same as the input format, each card should be printed with a character and an integer separated by a space character in a line.
 Arrange the missing cards in the following priorities:

Print cards of spades, hearts, clubs and diamonds in this order.

If the suits are equal, print cards with lower ranks first.

Sample Input

47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13

Sample Output

S 1
H 3
H 7
C 12
D 8

Note

      解説      

	



Sample input:
47
S 10
S 11
S 12
S 13
H 1
H 2
S 6
S 7
S 8
S 9
H 6
H 8
H 9
H 10
H 11
H 4
H 5
S 2
S 3
S 4
S 5
H 12
H 13
C 1
C 2
D 1
D 2
D 3
D 4
D 5
D 6
D 7
C 3
C 4
C 5
C 6
C 7
C 8
C 9
C 10
C 11
C 13
D 9
D 10
D 11
D 12
D 13


Sample output:
S 1
H 3
H 7
C 12
D 8

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

n = int(input())
a = ['']*n
b = [0]*n
for i in range(n):
    a[i],b[i] = input().split()

array_S = []
for i in range(13):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'S':
                break
        count += 1
        if count == n:
            array_S.append(i)
            
array_H = []
for i in range(13):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'H':
                break
        count += 1
        if count == n:
            array_H.append(i)

array_C = []
for i in range(13):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'C':
                break
        count += 1
        if count == n:
            array_C.append(i)
            
array_D = []
for i in range(13):
    count = 0
    for j in range(n):
        if i == int(b[j]):
            if a[j] == 'D':
                break
        count += 1
        if count == n:
            array_D.append(i)
            
for i in range(1,len(array_S)):
    print('S',array_S[i],sep =' ')
for i in range(1,len(array_H)):
    print('H',array_H[i],sep =' ')
for i in range(1,len(array_C)):
    print('C',array_C[i],sep =' ')
for i in range(1,len(array_D)):
    print('D',array_D[i],sep =' ')

Submission status: Wrong Answer

Solution code:
l = [x+' '+y for x in['S','H','C','D']for y in[str(i+1)for i in range(13)]]
for n in range(int(input())):
  l.remove(input())
print(i for i in l)

Submission status: Wrong Answer

Solution code:
cards = []
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
print(a)

Submission status: Wrong Answer

Solution code:
cards = []
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
print(cards)

Submission status: Wrong Answer

Solution code:
cards = []
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
print("\n" .join(cards))

Submission status: Wrong Answer

Solution code:
cards = []
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
print()
print("\n" .join(cards))

Submission status: Wrong Answer

Solution code:
cards = list()
mark = ["S","H","C","D"]
for i in (mark):
    for j in range(1,14):
        cards.append( i + " " + str(j) )
print(cards)
n = int(input())
for i in range(n):
    a = input()
    cards.remove(a)
print()
print("\n" .join(cards))

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3

import sys


def main():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 13):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3

import sys


def main():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
   
    lst = [card for card in sys.stdin.readline().split()]
    card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 13):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3

import sys


def main():
    # s: spades
    # h: hearts
    # c: clubs
    # d: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    card_symbols = ['S', 'H', 'C', 'D']

    n = int(sys.stdin.readline())
    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    for key, value in card_deck.items():
        card_deck[key].sort()

    for i in card_symbols:
        for card in range(1, 13):
            if not str(card) in card_deck[i]:
                print(i, card)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3

import sys


def init_card_deck():
    # S: spades
    # H: hearts
    # C: clubs
    # D: diamonds
    card_deck = {'S': [], 'H': [], 'C': [], 'D': []}
    n = int(sys.stdin.readline())

    for i in range(n):
        lst = [card for card in sys.stdin.readline().split()]
        card_deck[lst[0]].append(lst[1])

    return card_deck


def print_missing_cards(card_deck):
    card_symbols = ['S', 'H', 'C', 'D']
    missing_cards = ''

    for i in card_symbols:
        for card in range(1, 14):
            if not str(card) in card_deck[i]:
                print(i, card)


def main():
    print(print_missing_cards(init_card_deck()))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for m in range(int(count_card)):
        cards_remain.append(input().replace(" ",""))

for m in suit:
    for n in range(13):
        cards_set.append(m+str(n+1))

cards_lost=list(set(cards_set)-set(cards_remain))


for x in cards_lost:
    if x[0]=="S":
        output.append(x)
for x in cards_lost:
    if x[0]=="H":
        output.append(x)
for x in cards_lost:
    if x[0]=="C":
        output.append(x)
for x in cards_lost:
    if x[0]=="D":
        output.append(x)
        
for y in output:
        print(y[0]+" "+y[1])

Submission status: Wrong Answer

Solution code:
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for m in range(int(count_card)):
        cards_remain.append(input().replace(" ",""))

for m in suit:
    for n in range(13):
        cards_set.append(m+str(n+1))

cards_lost=sorted(list(set(cards_set)-set(cards_remain)))


for x in cards_lost:
    if x[0]=="S":
        output.append(x)
for x in cards_lost:
    if x[0]=="H":
        output.append(x)
for x in cards_lost:
    if x[0]=="C":
        output.append(x)
for x in cards_lost:
    if x[0]=="D":
        output.append(x)
        
for y in output:
        print(y[0]+" "+y[1])

Submission status: Wrong Answer

Solution code:
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for l in range(int(count_card)):
        cards_remain.append(input().replace(" ",""))

for m in suit:
    for n in range(13):
        cards_set.append(m+str(n+1))

for p in cards_set:
    if p not in  cards_remain:
        output.append(p)

print(" ".join(output))

Submission status: Wrong Answer

Solution code:
cards_remain=[]
suit=["S","H","C","D"]
cards_set=[]
output=[]

count_card=input()

for l in range(int(count_card)):
        cards_remain.append(input().replace(" ",""))

for m in suit:
    for n in range(13):
        cards_set.append(m+str(n+1))

for p in cards_set:
    if p not in  cards_remain:
        output.append(p)

for x in output:
        print(x[0]+" "+x[1])

Submission status: Wrong Answer

Solution code:
n = int(input())

S = [1]*13
H = [1]*13
C = [1]*13
D = [1]*13

for i in range(n):
    mark, number = map(str, input().split())
    num = int(number)
    if mark == "S":
        S[num-1] = 0
    if mark == "H":
        H[num-1] = 0
    if mark == "C":
        C[num-1] = 0
    if mark == "H":
        H[num-1] = 0

for i in range(13):
    if S[i]:
        print("S " + str(i+1))
for i in range(13):
    if H[i]:
        print("H " + str(i+1))
for i in range(13):
    if C[i]:
        print("C " + str(i+1))
for i in range(13):
    if D[i]:
        print("D " + str(i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())

S = [1]*13
H = [1]*13
C = [1]*13
D = [1]*13

for i in range(n):
    mark, number = map(str, input().split())
    num = int(number)
    if mark == "S":
        S[num-1] = 0
    if mark == "H":
        H[num-1] = 0
    if mark == "C":
        C[num-1] = 0
    if mark == "D":
        H[num-1] = 0

for i in range(13):
    if S[i]:
        print("S " + str(i+1))
for i in range(13):
    if H[i]:
        print("H " + str(i+1))
for i in range(13):
    if C[i]:
        print("C " + str(i+1))
for i in range(13):
    if D[i]:
        print("D " + str(i+1))

Submission status: Wrong Answer

Solution code:
n = int(input())

S = [1]*13
H = [1]*13
C = [1]*13
D = [1]*13

mark = [""]*n
num = [""]*n

for i in range(n):
    mark[i], num[i] = map(str, input().split())

for i in range(n):
    if mark[i] == "S":
        S[int(num[i])-1] = 0
    if mark[i] == "H":
        H[int(num[i])-1] = 0
    if mark[i] == "C":
        C[int(num[i])-1] = 0
    if mark[i] == "D":
        H[int(num[i])-1] = 0

for i in range(13):
    if S[i]:
        print("S " + str(i+1))
for i in range(13):
    if H[i]:
        print("H " + str(i+1))
for i in range(13):
    if C[i]:
        print("C " + str(i+1))
for i in range(13):
    if D[i]:
        print("D " + str(i+1))

Submission status: Wrong Answer

Solution code:
n = input()

data = {
    'S':[0 for x in range(13)],
    'H':[0 for x in range(13)],
    'C':[0 for x in range(13)],
    'D':[0 for x in range(13)]
}

for i in range(n):
    s,num = raw_input().split()
    data[s][int(num)-1] = 1

for a in['S','H','C','D']:
    for b in range(13):
        if data[a][b] == 0:
            print('{0},{1}'.format(a,b+1))

Submission status: Wrong Answer

Solution code:
A = [[i for i in range(1 ,14)] for j in range(4)]
a = int(input())
print(A)
for i in range(a):
    b,c = map(str,input().split())
    c=int(c)
    if b=="S":
        A[0].remove(c)
    if b=="H":
        A[1].remove(c)
    if b=="C":
        A[2].remove(c)
    if b=="D":
        A[3].remove(c)
def name(number,name):
    x=A[number]
    x=map(str,x)
    print("%s " %name+("\n%s " %name).join(x))
name(0,"S")
name(1,"H")
name(2,"C")
name(3,"D")

Submission status: Wrong Answer

Solution code:
A = [[i for i in range(1 ,14)] for j in range(4)]
a = int(input())
for i in range(a):
    b,c = map(str,input().split())
    c=int(c)
    if b=="S":
        A[0].remove(c)
    if b=="H":
        A[1].remove(c)
    if b=="C":
        A[2].remove(c)
    if b=="D":
        A[3].remove(c)
def name(number,name):
    x=A[number]
    x=map(str,x)
    print("%s " %name+("\n%s " %name).join(x))
name(0,"S")
name(1,"H")
name(2,"C")
name(3,"D")

Submission status: Wrong Answer

Solution code:
N = int(input())

FL =[]
for i in range(13):
 FL.append("S" + str(i+1))
for i in range(13):
 FL.append("H" + str(i+1))
for i in range(13):
 FL.append("C" + str(i+1))
for i in range(13):
 FL.append("D" + str(i+1))

for i in range(N):
 x,y = map(str, input().split())
 FL.remove(x + y)

for i in range(52 - N - 1):
 print(FL[i] + " ", end="")
print(FL[-1])

Submission status: Wrong Answer

Solution code:
N = int(input())

#??????????????????????????????
FL =[]
for i in range(13):
 FL.append("S " + str(i+1))
for i in range(13):
 FL.append("H " + str(i+1))
for i in range(13):
 FL.append("C " + str(i+1))
for i in range(13):
 FL.append("D " + str(i+1))

for i in range(N):
 D = str(input())
 FL.remove(D)

for i in range(52 - N - 1):
 print(FL[i])

Submission status: Wrong Answer

Solution code:
epochs = int(input())
patterns = ['S', 'H', 'C', 'D']
checker = {pattern: [True]*13 for pattern in patterns}
for i in range(epochs):
    pattern, num = input().split()
    num = int(num)
    checker[pattern][num-1] = False

for pattern in patterns:
    for i in range(13):
        if checker[pattern][i]:
            print(pattern, i)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/python

n = int(input())
card = [[0 for i in range(13)] for i in range(4)]
print(len(card[0]))
for i in range(n):
  a,b = (i for i in input().split())
  b = int(b)-1

  if a == 'S':
    card[0][b] = 1
  elif a == 'H':
    card[1][b] = 1
  elif a == 'C':
    card[2][b] = 1
  elif a == 'D':
    card[3][b] = 1

for i in range(4):
  for j in range(13):
    if card[i][j] == 0:
      if i == 0:
        print('S ', end = '')
      elif i == 1:
        print('H ', end = '')
      elif i == 2:
        print('C ', end = '')
      elif i == 3:
        print('D ', end = '')
      print(str(j + 1))

Submission status: Wrong Answer

Solution code:
Suits = ['S', 'H', 'C', 'D']
Taro = []
Missing = []
n = int(input())
for i in range(n):
    Taro.append(input())
for j in range(52):
    card = Suits[j//13] + ' ' + str(j % 13 + 1)
    if card not in Taro:
        Missing.append(card)
if Missing == []:
    print('\n'.join(Missing))

Submission status: Wrong Answer

Solution code:
N = int(input())
m = {
    'S': list(range(1, 14)),
    'H': list(range(1, 14)),
    'C': list(range(1, 14)),
    'D': list(range(1, 14))
}
for i in range(N):
    shape, num = input().strip().split(' ')
    num = int(num)
    m[shape].remove(num)
for k in m:
    if len(m[k]) > 0:
        for x in m[k]:
            print('%s %d' % (k, x))

Submission status: Wrong Answer

Solution code:
n=int(input())
S=[int(0) for i in range(14)]
H=[int(0) for i in range(14)]
D=[int(0) for i in range(14)]
C=[int(0) for i in range(14)]
for i in range(n):
    K,y=[(i) for i in input().split()]
    if K=='S':
        S[int(y)]=1
    elif K=='H':
        H[int(y)]=1
    elif K=='D':
        D[int(y)]=1
    else:
        C[int(y)]=1
for i in range(14):
    if S==0:
        print('S'," {0}".format(i))
for i in range(14):
    if H==0:
        print('H'," {0}".format(i))
for i in range(14):
    if D==0:
        print('D'," {0}".format(i))
for i in range(14):
    if C==0:
        print('C'," {0}".format(i))

Submission status: Wrong Answer

Solution code:
n=int(input())
S=[int(0) for i in range(1,14)]
H=[int(0) for i in range(1,14)]
D=[int(0) for i in range(1,14)]
C=[int(0) for i in range(1,14)]
for i in range(n):
    K,y=[(i) for i in input().split()]
    if K=='S':
        S[int(y)-1]=1
    elif K=='H':
        H[int(y)-1]=1
    elif K=='D':
        D[int(y)-1]=1
    else:
        C[int(y)-1]=1
for i in range(1,14):
    if S[int(i)-1]==0:
        print('S',"{0}".format(i))
for i in range(1,14):
    if H[int(i)-1]==0:
        print('H',"{0}".format(i))
for i in range(1,14):
    if D[int(i)-1]==0:
        print('D',"{0}".format(i))
for i in range(1,14):
    if C[int(i)-1]==0:
        print('C',"{0}".format(i))

Submission status: Wrong Answer

Solution code:
pri = {'S':0,'H':13,'C':26,'D':39}
total_cards = set()
for pic in pri.keys():
	for rank in range(1,14):
		total_cards.add(pic + ' ' + str(rank))
cards = set()
for _ in range(eval(input())):
	cards.add(input())
no_cards = list(total_cards - cards)
no_cards.sort(key = lambda c: pri[c[0]] + int(c[2]))
for i in range(len(no_cards)):
	print(no_cards[i])

Submission status: Wrong Answer

Solution code:
n=int(input())
card_have=[input().split() for i in range(n)]

nums={1,2,3,4,5,6,7,8,9,10,11,12,13}

s_have={int(s[1]) for s in card_have if s[0]=="S"}
h_have={int(h[1]) for h in card_have if h[0]=="H"}
c_have={int(c[1]) for c in card_have if c[0]=="C"}
d_have={int(d[1]) for d in card_have if d[0]=="S"}

s_lost=list(nums^s_have)
h_lost=list(nums^h_have)
c_lost=list(nums^c_have)
d_lost=list(nums^d_have)

s_lost.sort()
h_lost.sort()
c_lost.sort()
d_lost.sort()

for s in s_lost:
    print("S",s)
for h in h_lost:
    print("H",h)
for c in c_lost:
    print("C",c)
for d in d_lost:
    print("D",d)

Submission status: Wrong Answer

Solution code:
N = int(input())
S = ["S"]
H = ["H"]
C = ["C"]
D = ["D"]
for i in range(N):
    s, n = input().split()
    if s == "S":
        S.append(int(n))
    elif s == "H":
        H.append(int(n))
    elif s == "C":
        C.append(int(n))
    else:
        D.append(int(n))

def finder(d):
    for j in range(1, len(d)+1):
        if j not in d:
            print(d[0], j)

finder(S)
finder(H)
finder(C)
finder(D)

Submission status: Wrong Answer

Solution code:
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
for _ in range(n):
    suit,num = input().split()
    if   suit=='S': cards[0][int(num)-1] = 0
    elif suit=='H': cards[1][int(num)-1] = 0
    elif suit=='C': cards[2][int(num)-1] = 0
    elif suit=='D': cards[3][int(num)-1] = 0
for s in cards:
    if n!=0: print(n)

Submission status: Wrong Answer

Solution code:
import itertools
n = int(input())
c = list(itertools.product(['S', 'H', 'C', 'D'], range(1,14)))
for _ in range(n):
    s, num = input().split()
    c.remove((s, int(num)))
for i in range(4*13 - n):
    print(*c, sep = '\n')

Submission status: Wrong Answer

Solution code:
all_cards = [[],[],[],[]]
for i in range(4):
	for j in range(13):
		all_cards[i].append(j+1)

n = int(raw_input())
for i in range(n):
	card = raw_input().split(" ")
	print card
	if card[0] == "S":
		all_cards[0].remove(int(card[1]))
	elif card[0] == "H":
		all_cards[1].remove(int(card[1]))
	elif card[0] == "C":
		all_cards[2].remove(int(card[1]))
	else:
		all_cards[3].remove(int(card[1]))

for i in range(len(all_cards[0])):
	print("S {:}".format(all_cards[0][i]))
for i in range(len(all_cards[1])):
	print("H {:}".format(all_cards[1][i]))
for i in range(len(all_cards[2])):
	print("C {:}".format(all_cards[2][i]))
for i in range(len(all_cards[3])):
	print("D {:}".format(all_cards[3][i]))

Submission status: Wrong Answer

Solution code:
def main():
    
    deck = set()
    for item in range(1,14):
        deck = deck | {('H ' + str(item))}
        deck = deck | {('D ' + str(item))}
        deck = deck | {('C ' + str(item))}
        deck = deck | {('S ' + str(item))}
    suits_order = ['S', 'H', 'C', 'D']
    
    n = int(input())
    cards = [input() for i in range(n)]
    remains = sorted(sorted(list(deck - set(cards)), key = lambda x: suits_order.index(x[:1])), key = lambda x: int(x[2:]))
    for item in remains:
        print(item)


main()

Submission status: Wrong Answer

Solution code:
import sys
dict={}
suit=['S','H','C','D']
input()
lines=sys.stdin.readlines()

'''
lines=['S 2','S 3','S 4','S 6','D 1','H 2','C 12'
'''
for l in lines: dict[l]=True

for i in range(4):
    for j in range(1,14):
        s=suit[i]+' '+str(j)
        if not(dict.get(s,False)): print(s)

Submission status: Wrong Answer

Solution code:
import sys

dict={}
suit=['S','H','C','D']
input()
lines=sys.stdin.readlines()

for l in lines: dict[l]=True

for i in range(4):
    for j in range(1,14):
        s=suit[i]+' '+str(j)
        if not(dict.get(s,False)): print(s)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    nums = set(range(1, 13 + 1))

    cards = {
        "S": set(),
        "H": set(),
        "C": set(),
        "D": set(),
    }
    for _ in range(n):
        mark, num = input().split()
        cards[mark].add(int(num))

    for mark in ("S", "H", "C", "D"):
        a = nums - cards[mark]
        for num in a:
            print(mark, num)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8

suits = {"S": 0, "H": 1, "C": 2, "D": 3}
tramp_list = [0 for i in range(52)]
n = int(input())

for j in range(n):
    card = input().split()
    card_number = suits[card[0]]*13 + int(card[1]) - 1
    tramp_list[card_number] = 1

for k in range(52):
    if tramp_list[k] == 0:
        suit_key = (k+1) // 13
        number_key = (k+1) % 13
        the_suit = 'undefined'

        for suit_name, suit_number in suits.items():
            if suit_number == suit_key:
                the_suit = suit_name

        print('{0} {1}'.format(the_suit, number_key))

Submission status: Wrong Answer

Solution code:
number = int(input())
dict = {}
for x in ["S","H","C","D"]:
        dict[x] = [i for i in range(1,14)]
for i in range(number):
    x,y = map(str,input().split())
    dict[x].remove(int(y))
print(dict)

Submission status: Wrong Answer

Solution code:
'''
?????????????????????
??????????????¨??????????????\?????????
???????????????????????¨????????????
??????????????????
????????????????????£????¶????????????°???????????????????????????
?¬????????????????????????°??????1??\????????????
??????????????¨?????????????????????????????????????????¨??????????????°????????????????????????
??????1??\???????????°??????????????????????¬???????????????¨???????????????
???????????£?????????????????¨??????????????\?????????
??£?????¨??????????????????????????????
??????????????????????????????????????£????????????????????\?????§??§????????????
??????????????????????????????????????????????????§????????°??§????????????
??§?????£?????¨?????§?????£?????????????????´??????

??£?????¨?????§?????¶??????????????????????????????????´????
????????????????????????????????°??????????????????
????????????????????£???????????°?????????????????????1????????§???????????°?¶????????????°??????
?????????????????\???????????????????´????
?????????4???????????¶??????????????????????????????

??°??????????????£???int????????????
??°???????????????????????¨???????????????????´??????????????????¨?????????????????????????¶??????°????????????

??????2??\????????????????????´???????????????????????????
'''


import re

#eCard = ['S 1', 'S 5', 'H 1', 'D 2', 'C 8', 'S 13']
eCard = []
n = int(input())
i = 0
while i < n:
    eCard.append(input())
    i += 1

#print(eCard)
#???????????????????????£?????¨?????§????´¢???????????????
S = []
H = []
D = []
C = []

missingS = []
missingH = []
missingD = []
missingC = []


def assortSuit(s, sc):
    i = 0

#??????????????????????????¢?????\?????????????????????
    while i < int(len(eCard)):
        if re.match(s, eCard[i]):
            Smatch = re.search('\d+', eCard[i])
            sc.append(int(Smatch.group()))#????????????????????????????????£?????????????????¨???????????°???????????????
        i += 1

#S = re.search(???^S.*???, eCard)
assortSuit('^S', S)
assortSuit('^H', H)
assortSuit('^D', D)
assortSuit('^C', C)

def selectMissingCards(c, mc):
    c.sort()
#???????????°???????°?????????°????????????????????¨???
    smallerC = 1
    while smallerC < c[0]:
        mc.append(smallerC)
        smallerC += 1
        
        
    i = 0

    while i < len(c)-1:
        m = c[i+1] - c[i]
    
        if m > 1:
            h = 1
            while h < m:
                mc.append(c[i]+h)
                h += 1
        i += 1
    largerC = c[i] + 1
    while largerC <= 13:
        mc.append(largerC)
        largerC += 1
        
            

selectMissingCards(S, missingS)
selectMissingCards(H, missingH)
selectMissingCards(D, missingD)
selectMissingCards(C, missingC)

'''
print(missingS)
print(missingH)
print(missingD)
print(missingC)
'''

missingCards = []

def allMissingCards(mc, s):
    #??????????????????????????????????????°?????????????????????????????????????????????????´????
    i = 0
    while i < len(mc):
        missingCards.append(s + str(mc[i]))
        i += 1
    
allMissingCards(missingS, "S ")
allMissingCards(missingH, "H ")
allMissingCards(missingD, "D ")
allMissingCards(missingC, "C ")

#print(missingCards)

i = 0
while i < len(missingCards):
    print(missingCards[i])
    i += 1
    


'''
if S:
    #??°?????????????????????????´????
    
    Scard = re.search(???\d+???, S)#?????????????????????????????????????????£?????¨???????????§?????????????????°??????????????¨???
    SeCard = []
    SeCard.append(int(Scard.group()))
    print(SeCard)
'''

Submission status: Wrong Answer

Solution code:
n = input()
a = []
for i in range(n):
	x,y = raw_input().split()
	z = int(y)
	if x == 'S':
		pass
	elif x == 'H':
		z += 13
	elif x == 'C':
		z += 26
	else:
		z += 39
	a.append(z)
b = []
for j in range(1,53):
	if j in a:
		pass
	else:
		b.append(j)
i = 0
for k in range(0, int(len(b))):
	while True:
		if b[k] <= 13: break
		i += 1
		b[k] = b[k] - 13
	if i == 0:	print 'S %d' %b[k]
	elif i == 1:print 'H %d' %b[k]
	elif i == 2:print 'C %d' %b[k]	
	else:print 'D %d' %b[k]

Submission status: Wrong Answer

Solution code:
n = input()
a = []
for i in range(n):
	x,y = raw_input().split()
	z = int(y)
	if x == 'S':
		pass
	elif x == 'H':
		z += 13
	elif x == 'C':
		z += 26
	else:
		z += 39
	a.append(z)
a.sort()
b = []
for j in range(1,53):
	if j in a:
		pass
	else:
		b.append(j)
print b

Submission status: Wrong Answer

Solution code:
# coding:utf-8
n = input()
card = []
for i in range(1,14):
    card.append(('S', str(i)))
for i in range(1,14):
    card.append(('H', str(i)))
for i in range(1,14):
    card.append(('C', str(i)))
for i in range(1,14):
    card.append(('D', str(i)))
array = [raw_input().split() for i in range(n)]
src_set = set(card)
array_set = set(map(tuple, array))
answer = src_set ^ array_set
for v1,v2 in answer:
    print v1,v2

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
a.reverse()
print(" ".join(a))

Submission status: Wrong Answer

Solution code:
h = [i for i in range(1,14)]
c = [i for i in range(1,14)]
d = [i for i in range(1,14)]
s = [i for i in range(1,14)]

x = int(input())

for i in range(x):
    ss, nn = map(str, input().split())

    try:
        if ss == "H":
            h.remove(int(nn))
        elif ss == "C":
            c.remove(int(nn))
        elif ss == "D":
            h.remove(int(nn))
        elif ss == "S":
            h.remove(int(nn))
    except ValueError:
        break

for i in range(len(s)):
    print ("S "+ str(s[i]))
    
for i in range(len(h)):
    print ("H "+ str(h[i]))

for i in range(len(c)):
    print ("C "+ str(c[i]))

for i in range(len(d)):
    print ("D "+ str(d[i]))

Submission status: Wrong Answer

Solution code:
Cards = [
    "S 1", "H 1", "C 1", "D 1",
    "S 2", "H 2", "C 2", "D 2",
    "S 3", "H 3", "C 3", "D 3",
    "S 4", "H 4", "C 4", "D 4",
    "S 5", "H 5", "C 5", "D 5",
    "S 6", "H 6", "C 6", "D 6",
    "S 7", "H 7", "C 7", "D 7",
    "S 8", "H 8", "C 8", "D 8",
    "S 9", "H 9", "C 9", "D 9",
    "S 10", "H 10", "C 10", "D 10",
    "S 11", "H 11", "C 11", "D 11",
    "S 12", "H 12", "C 12", "D 12",
    "S 13", "H 13", "C 13", "D 13",
]

n = input()

for i in range(int(n)):
    rm = input()
    Cards.remove(rm)

for i in range(52 - int(n)):
    print(Cards.pop(0))

Submission status: Wrong Answer

Solution code:
cards = []
for i in set({'S','H','C','D'}):
    for j in range(1, 14):
        cards.append(i + " " + str(j))
N = int(input())
for i in range(N):
    cards.remove(input())

for i in range(len(cards)):
    print (cards[i])

Submission status: Wrong Answer

Solution code:
l = []
for i in range(1,14):
    l.append("S "+str(i))
for i in range(1,14):
    l.append("H "+str(i))
for i in range(1,14):
    l.append("C "+str(i))
for i in range(1,14):
    l.append("D "+str(i))
num = int(input())
for i in range(num):
    l.remove(input(()))

for i in range(52-num):
    print(l[i])

Submission status: Wrong Answer

Solution code:
l=["S 1","S 2","S 3","S 4","S 5","S 6","S 7","S 8","S 9","S 10","S 11","S 12","S 13","H 1","H 2","H 3","H 4","H 5","H 6","H 7","H 8","H 9","H 10","H 11","H 12","H 13","C 1","C 2","C 3","C 4","C 5","C 6","C 7","C 8","C 9","C 10","C 11","C 12","C 13","D 1","D 2","D 3","D 4","D 5","D 6","D 7","D 8","D 9","D 10","D 11","D 12","D 13"]
for i in range(int(input())):
    l.remove(input(()))

for i in l:
    print(i)

Submission status: Wrong Answer

Solution code:
import sys

cards_num = int(sys.stdin.readline())
cards =[ card[:-1] for card in sys.stdin.readlines() ]

print(cards_num)
print(cards)

all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ]

missing_cards = [i for i in all_cards if not(i in cards) ]

for s in missing_cards:
    print(s)

Submission status: Wrong Answer

Solution code:
import sys

cards_num = int(sys.stdin.readline())
cards =[ card[:-1] for card in sys.stdin.readlines() ]

print(cards_num)
print(cards)

all_cards = [ i + ' ' + str(j) for i in 'SHCD' for j in range(1,14) ]

missing_cards = [i for i in all_cards if not(i in cards) ]

for s in missing_cards:
    print(s,end='')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
dict_list = defaultdict(list)
out_list = defaultdict(list)
count = int(input())
for i in range(count):
    x, y = input().split()
    dict_list[x].append(int(y))

for key, value in dict_list.items():
    for num in range(1, 14):
        if num not in value:
            out_list[key].append(num)

for key, value in out_list.items():
    for num in value:
        print('{a} {b}'.format(a=key, b=num))

Submission status: Wrong Answer

Solution code:
import sys

l = []
keys = []
dicts = {}
for i in sys.stdin:
    l.append(i)

for i in range(1,len(l)):
    l[i] = l[i].split()

for i in range(1,len(l)):
    if l[i][0] not in keys:
        keys.append(l[i][0])

for i in range(1,len(l)):
    if l[i][0] not in dicts:
        a = []
        a.append(int(l[i][1]))
        dicts[l[i][0]] = a
    else:
        dicts[l[i][0]].append(int(l[i][1]))

for key in dicts:
    dicts[key] = sorted(dicts[key])

for data in keys:
    for j in range(1,14):
        if j not in dicts[data]:
            print(data,j)