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: Accepted

Solution code:
n = int(input())
S_flag = [0] * 13
H_flag = [0] * 13
C_flag = [0] * 13
D_flag = [0] * 13
for i in range(n):
    mark , number = input().split()
    if mark == "S":
        S_flag[int( number )-1] = 1
    elif mark == "H":
        H_flag[int( number )-1] = 1
    elif mark == "D":
        D_flag[int( number )-1] = 1
    elif mark == "C":
        C_flag[int( number )-1] = 1

for i in range(13):
    if S_flag[i] == 0:
        print("S " + str( i + 1 ))

for i in range(13):
    if H_flag[i] == 0:
        print("H " + str( i + 1 ))

for i in range(13):
    if C_flag[i] == 0:
        print("C " + str( i + 1 ))

for i in range(13):
    if D_flag[i] == 0:
        print("D " + str( i + 1 ))

Submission status: Accepted

Solution code:
table = [[0 for i in range(13)] for i in range(4)]
suit = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
inv_suit = {v: k for k, v in suit.items()}
n = int(input())

for i in range(n):
    line = input().split()
    s = line[0]
    n = int(line[1])
    table[suit[s]][n-1] = 1

for i in range(len(table)):
    for j in range(len(table[i])):
        if table[i][j] == 0:
            print('{} {}'.format(inv_suit[i], j+1))

Submission status: Accepted

Solution code:
N=int(input())
suits=["S","H","C","D"]
cards=[]
for _ in range(N):
    s,n=input().split()
    if s=="S":
        cards.append(int(n))
    elif s=="H":
        cards.append(13+int(n))
    elif s=="C":
        cards.append(26+int(n))
    else:
        cards.append(39+int(n))
        
for i in range(1,53):
    if i not in cards:
        print(suits[(i-1)//13],(i-1)%13+1)

Submission status: Accepted

Solution code:
cards = [[False for y in range(13)] for x in range(4)]
suit2num = {"S": 0, "H": 1, "C": 2, "D": 3}
num2suit = {"0": "S", "1": "H", "2": "C", "3": "D"}

n = int(input())
for i in range(n):
    s, n = input().split()
    cards[suit2num[s]][int(n) - 1] = True

for i in range(4):
    suit = num2suit[str(i)]
    for j in range(13):
        if cards[i][j] == False:
            print(suit + " " + str(j + 1))

Submission status: Accepted

Solution code:
from collections import defaultdict

def mapt(fn, *args):
    return tuple(map(fn, *args))


def Atom(strings):
    return int(strings) if strings.isdigit() else strings


def symmetric(setseq):
    a = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}
    return a^setseq

    
n = int(input())
dataset = [mapt(Atom, input().split(" ")) for i in range(n)]
a = defaultdict(list)

for key, value in dataset:
    a[key].append(value)

for key, value in a.items():
    a[key] = symmetric(set(value))
    
for i in ("S", "H", "C", "D"):
    for value in (a.get(i)):
        print(i, value)

Submission status: Accepted

Solution code:
#
# 6b
#

def main():
    n = int(input())
    c = []
    for i in range(n):
        m, r = input().split()
        r = int(r)
        c.append([m, r])
    for M in ["S", "H", "C", "D"]:
        for R in range(1, 14):
            for i in range(n):
                if c[i] == [M, R]:
                    break
            else:
                print(*[M, R])


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=[]
H=[]
C=[]
D=[]
n=int(input())
for i in range(n):
    a,b=map(str,input().split())
    if a=='S':
        S.append(b)
    elif a=='H':
        H.append(b)
    elif a=='C':
        C.append(b)
    else:
        D.append(b)
S=list(map(int,S))
H=list(map(int,H))
C=list(map(int,C))
D=list(map(int,D))
for j in range(13):
    if not j+1 in S:
        print('S',j+1)
for k in range(13):
    if not k+1 in H:
        print('H',k+1)
for l in range(13):
    if not l+1 in C:
        print('C',l+1)
for m in range(13):
    if not m+1 in D:
        print('D',m+1)

Submission status: Accepted

Solution code:
n=int(input())
a=[]
for i in range(n):
    x,y=input().split()
    y=int(y)
    if x == "S":
        a.append(y+0)
    if x == "H":
        a.append(y+13)
    if x == "C":
        a.append(y+26)
    if x == "D":
        a.append(y+39)
for i in range(1,53):
        if not(i in a):
            if i<=13:
                print("S {}".format(i - 0))
            elif i<=26:
                print("H {}".format(i - 13))
            elif i<=39:
                print("C {}".format(i - 26))
            else:
                print("D {}".format(i - 39))

Submission status: Accepted

Solution code:
all_cards = []
[all_cards.append((s, nu)) for s in ['S', 'H', 'C', 'D'] for nu in range(1, 14)]

n = int(input())
hold_cards = []
for i in range(n):
    suit, num = input().split()
    num = int(num)
    hold_cards.append((suit, num))
for card in all_cards:
    if card not in set(hold_cards):
        print(*card)

Submission status: Accepted

Solution code:
n = int(input())
S = list()
H = list()
C = list()
D = list()
for i in range(13):
  S.append(i+1)
  H.append(i+1)
  C.append(i+1)
  D.append(i+1)
  
for i in range(n):
  card = input().split()
  if card[0]=='S':
    S.remove(int(card[1]))
  if card[0]=='H':
    H.remove(int(card[1]))
  if card[0]=='C':
    C.remove(int(card[1]))
  if card[0]=='D':
    D.remove(int(card[1]))

for i in range(len(S)):
  print('S',S[i])
for i in range(len(H)):
  print('H',H[i])
for i in range(len(C)):
  print('C',C[i])
for i in range(len(D)):
  print('D',D[i])

Submission status: Accepted

Solution code:
cards = ['{} {}'.format(s, r) for s in ('S', 'H', 'C', 'D') for r in range (1, 14)]
a = int(input())
for i in range(a):
    b = input()
    cards.remove(b)
for j in cards:
    print(j)

Submission status: Accepted

Solution code:
n = int(input())
card = list()
mark = ['S','H','C','D']
for i in range(n):
 a,b = input().split()
 b = int(b)
 if a == 'S': card.append(0+b)
 elif a == 'H': card.append(13+b)
 elif a == 'C': card.append(26+b)
 else: card.append(39+b)
for i in range(1,53):
 if not (i in card): 
     print(mark[(i-1)//13],(i-1)%13+1)

Submission status: Accepted

Solution code:
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S": a.append(y + 0)
	elif x == "H": a.append(y + 13)
	elif x == "C": a.append(y + 26)
	else: a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13: print("S {}".format(i - 0))
		elif i <= 26: print("H {}".format(i - 13))
		elif i <= 39: print("C {}".format(i - 26))
		else: print("D {}".format(i - 39))

Submission status: Accepted

Solution code:
n=int(input())
S=list(i for i in range(1, 14))
H=list(i for i in range(1, 14))
C=list(i for i in range(1, 14))
D=list(i for i in range(1, 14))

for i in range(n) :
    x,y=map(str,input().split())
    
    if x=="S":
        S.remove(int(y))
    elif x=="H":
        H.remove(int(y))
    elif x=="C":
        C.remove(int(y))
    else:
        D.remove(int(y))
        
if len(S)>0:
    for i in range(len(S)):
        print(f'S {S[i]}')
if len(H)>0:
    for i in range(len(H)):
        print(f'H {H[i]}')
if len(C)>0:
    for i in range(len(C)):
        print(f'C {C[i]}')
if len(D)>0:
    for i in range(len(D)):
        print(f'D {D[i]}')

Submission status: Accepted

Solution code:
from collections import OrderedDict

# トランプの生成
cards = OrderedDict()  # 順序付き辞書
for s in ['S', 'H', 'C', 'D']:
    for r in range(1, 13 + 1):
        key = "{} {}".format(s, r)
        cards[key] = False

count = int(input())

# 所持しているトランプの処理
for n in range(count):
    input_key = input()
    cards[input_key] = not(cards[input_key])  # 真理値を反転 (Trueへ)

# 不足しているトランプの表示
for k, v in cards.items():
    if not v:
        print(k)

Submission status: Accepted

Solution code:
n = int(input())
card = []

pattern = ["S","H","C","D"] 
for i in pattern:
    for j in range(1, 14):
        card.append([i, j])

for i in range(1, n+1):
    a, b = input().split()
    card.remove([a, int(b)])
    
for i in range(len(card)):
    print(*card[i])

Submission status: Accepted

Solution code:
a=int(input())
cards = []
for c in ['S', 'H', 'C', 'D']:
  for n in range(1, 14):
    cards.append(f'{c} {n}')

for i in range(a):
    x=input()
    if x in cards:
        cards.remove(x)
for i in range(len(cards)):
    print(cards[i])

Submission status: Accepted

Solution code:
n = int(input())
s = "SHCD"
cards = [[0] * 13 for i in range(4)]
for i in range(n):
  a, b = input().split()
  cards[s.find(a)][int(b)-1] = 1
for i in range(4):
  for j in range(13):
    if cards[i][j] == 0:
      print(s[i], j+1)

Submission status: Accepted

Solution code:
n = int(input())
card = [[False for i in range(13)] for j in range(4)]

for i in range(n) :
    mark, suit = input().split()
    if mark == "S" :
        mark_num = 0
    elif mark == "H" :
        mark_num = 1
    elif mark == "C" :
        mark_num = 2
    elif mark == "D" :
        mark_num = 3
    card[mark_num][int(suit)-1] = True

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = int(input())
c = "SHCD"

card = [[0] * 13 for i in range(4)]
for i in range(n):
    a,b = input().split()
    card[c.find(a)][int(b)-1] = 1
for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(c[i], j+1)

Submission status: Accepted

Solution code:
rows = int(input())
LstS = []
LstH = []
LstC = []
LstD=[]

for i in range(rows):
    x, y = input().split()
    if x == "S":
        LstS.append(int(y))
    elif x == "H":
        LstH.append(int(y))
    elif x == "C":
        LstC.append(int(y))
    elif x == "D":
        LstD.append(int(y))

LstS.sort
LstH.sort
LstD.sort
LstC.sort

for i in range(1,14,1):
    if LstS.count(i) == 0:
        print("S",end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstH.count(i) == 0:
        print("H", end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstC.count(i) == 0:
        print("C", end=" ")
        print(i)

for i in range(1, 14, 1):
    if LstD.count(i) == 0:
        print("D", end=" ")
        print(i)

Submission status: Accepted

Solution code:
num = list(range(1, 14))

spairs = 13 * ['S'] + num
hpairs = 13 * ['H'] + num
cpairs = 13 * ['C'] + num
dpairs = 13 * ['D'] + num

n = int(input())
s, h, c, d = 4*[0]
for i in range(n):
    a, b = input().split()
    if a == 'S':
        spairs.remove(a)
        spairs.remove(int(b))
        s += 1
    if a == 'H':
        hpairs.remove(a)
        hpairs.remove(int(b))
        h += 1
    if a == 'C':
        cpairs.remove(a)
        cpairs.remove(int(b))
        c += 1
    if a == 'D':
        dpairs.remove(a)
        dpairs.remove(int(b))
        d += 1

for i in range(13 - s):
    print(*[spairs[i], spairs[i + 13 - s]])
for i in range(13 - h):
    print(*[hpairs[i], hpairs[i + 13 - h]])
for i in range(13 - c):
    print(*[cpairs[i], cpairs[i + 13 - c]])
for i in range(13 - d):
    print(*[dpairs[i], dpairs[i + 13 - d]])

Submission status: Accepted

Solution code:
N = int(input())
suits = ["S", "H","C","D"]
cards = []

for _ in range(N):
    s,n = input().split()
    if s == "S":
        cards.append(int(n))
    if s == "H":
        cards.append(int(n)+13)
    if s == "C":
        cards.append(int(n)+26)
    if s == "D":
        cards.append(int(n)+39)
    
for i in range(1,53):
    if i not in cards: 
        print(suits[(i-1)//13],(i-1)%13+1)

Submission status: Accepted

Solution code:
S_list= list(range(1, 14))
H_list= list(range(1, 14))
C_list= list(range(1, 14))
D_list= list(range(1, 14))
a = int(input())
for i in range(a):
    x,y = map(str,input().split())
    if x == 'S':
        S_list.remove(int(y))
    elif x == 'H':
        H_list.remove(int(y))
    elif x == 'C':
        C_list.remove(int(y))
    elif x == 'D':
        D_list.remove(int(y))

for item in S_list:
    print('S '+str(item))
for item in H_list:
    print('H '+str(item))
for item in C_list:
    print('C '+str(item))
for item in D_list:
    print('D '+str(item))

Submission status: Accepted

Solution code:
n = int(input())
cardslist = []

for i in range(n):
    input_cards = input()
    cardslist.append(input_cards)

for mark in "SHCD":
    for i in range(1, 14):
        if mark + ' ' + str(i) not in cardslist:
            print(mark + ' ' + str(i))

Submission status: Accepted

Solution code:
n=int(input())
tbl=[[0 for i in range(2)]for j in range(n)]
for i in range(n):
    var=input()
    var=var.split()
    tbl[i][0]=var[0]
    tbl[i][1]=int(var[1])
for i in range(1,14):
    if((['S',i] in tbl)==False):
        print("S "+str(i))
for i in range(1,14):
    if((['H',i] in tbl)==False):
        print("H "+str(i))
for i in range(1,14):
    if((['C',i] in tbl)==False):
        print("C "+str(i))
for i in range(1,14):
    if((['D',i] in tbl)==False):
        print("D "+str(i))

Submission status: Accepted

Solution code:
N = int(input())
lst = []
for i in range(N):
    lst.append(input().split())
for k in ["S","H","C","D"]:
    for j in range(1,14):
        if [k,str(j)] not in lst:
            print(k,j)

Submission status: Accepted

Solution code:
#68 不足しているカードの発見

n = int(input())

s = "SHCD"
card = [[0] * 13 for i in range(4)]
for i in range(n):
    a, b = input().split()
    card[s.find(a)][int(b) - 1] = 1     
for i in range(4):
    for j in range(13):
        if card[i][j] == 0:
            print(s[i], j + 1)

Submission status: Accepted

Solution code:
n = int(input())
list = [input() for i in range(n)]
for i in ["S","H","C","D"]:
    for j in range(1,14):
        card = i + " " + str(j)
        if not (card in list):
            print(card)

Submission status: Accepted

Solution code:
C = []
for _ in range(4):
    c = [i for i in range(1, 14)]
    C.append(c)
n = int(input())
for _ in range(n):
    i, j = map(str, input().split())
    j = int(j)
    if i == 'S':
        C[0][j - 1] = 0
    elif i == 'H':
        C[1][j - 1] = 0
    elif i == 'C':
        C[2][j - 1] = 0
    else:
        C[3][j - 1] = 0
for i in range(4):
    for j in range(13):
        if C[i][j] != 0:
            if i == 0:
                print('S', end=' ')
                print(j + 1)
            elif i == 1:
                print('H', end=' ')
                print(j + 1)
            elif i == 2:
                print('C', end=' ')
                print(j + 1)
            else:
                print('D', end=' ')
                print(j + 1)

Submission status: Accepted

Solution code:
num=int(input())
cardList=[input().split(" ")for i in range(num)]
pattern=["S","H","C","D"]
notOwned=[]
for i in range(4):
    for j in range(1,14):
        if not([pattern[i],str(j)] in cardList):
            notOwned.append(pattern[i]+" "+str(j))
for i in notOwned:
    print(i)

Submission status: Accepted

Solution code:
i=0
j=0
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]
n = int(input())
for k in range(n):
   m,s = input().split()
   s = int(s)
   cards[pattern.index(m)][s-1] = True
for i in range(4):
   for j in range(13):
      if cards[i][j] == False:
         print(pattern[i], j+1)
      else:
         pass

Submission status: Accepted

Solution code:
n=int(input())
card=[[False for i in range(13)] for j in range(4)]
for i in range(n):
    mark,rank=input().split()
    if mark=="S":
        pattern=0
    elif mark=='H':
        pattern=1
    elif mark=='C':
        pattern=2
    elif mark=='D':
        pattern=3
    card[pattern][int(rank)-1]=True
for j in range(4):
    for i in range(13):
        if card[j][i]==False:
            if j==0:
                print('S',i+1)
            elif j==1:
                print('H',i+1)
            elif j==2:
                print('C',i+1)
            elif j==3:
                print('D',i+1)

Submission status: Accepted

Solution code:

num = int(input())

slist = list()
hlist = list()
clist = list()
dlist = list()

for i in range(num):

    mark,value = input().split()
    if (mark == "S"):
        slist.append(value)

    elif (mark == "H"):
        hlist.append(value)

    elif (mark == "C"):
        clist.append(value)

    elif (mark == "D"):
        dlist.append(value)





nslist = list()
nhlist = list()
nclist = list()
ndlist = list()

for i in range(1,14):
    if (str(i) not in slist):
        nslist.append(str(i))

for i in range(1,14):
    if (str(i) not in hlist):
        nhlist.append(str(i))

for i in range(1,14):
    if (str(i) not in clist):
        nclist.append(str(i))

for i in range(1,14):
    if (str(i) not in dlist):
        ndlist.append(str(i))

for j in nslist:
    print("S "+str(j))

for j in nhlist:
    print("H "+str(j))

for j in nclist:
    print("C "+str(j))

for j in ndlist:
    print("D "+str(j))

Submission status: Accepted

Solution code:
A=int(input())
s=list(range(1,14))
h=list(range(1,14))
c=list(range(1,14))
d=list(range(1,14))

for i in range(A):
    M,N=map(str,input().split())
    N=int(N)
    
    if M=='S':
        s[N-1]=0
    
    if M=='H':
        h[N-1]=0
        
    if M=='C':
        c[N-1]=0
        
    if M=='D':
        d[N-1]=0
        
for j in range(13):
    if s[j]==0:
        pass
    else:
        print('S',s[j])
        
for k in range(13):
    if h[k]==0:
        pass
    else:
        print('H',h[k])
        
for l in range(13):
    if c[l]==0:
        pass
    else:
        print('C',c[l])

for m in range(13):
    if d[m]==0:
        pass
    else:
        print('D',d[m])

Submission status: Accepted

Solution code:
n = int(input())
i = 0
card = []
cards = []
while i < n:
    card = list(map(str, input().split()))
    cards.append(card)
    i += 1

#print(cards)

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

for i in range(n):
    card = cards[i]
    m = card[0]
    num = int(card[1])
    if m == "S":
        s.remove(num)
    elif m == "H":
        h.remove(num)
    elif m == "C":
        c.remove(num)
    else:
        d.remove(num)

for i in range(len(s)):
    (print("S {}" .format(s[i])))
for i in range(len(h)):
    (print("H {}" .format(h[i])))
for i in range(len(c)):
    (print("C {}" .format(c[i])))
for i in range(len(d)):
    (print("D {}" .format(d[i])))

Submission status: Accepted

Solution code:
n=int(input())
lis=list()
for i in range(n):
    a,b=map(str,input().split())
    b=int(b)
    
    if a=="S":
        lis.append(b)
    elif a=="H":
        lis.append(b+13)
    elif a=="C":
        lis.append(b+26)
    elif a=="D":
        lis.append(b+39)
        
for i in range(1, 53):
	if not (i in lis):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))

Submission status: Accepted

Solution code:
n = int(input())    #Taro cardの枚数
card=[[0]*13 for _ in range(4)]
for i in range(n):
    t, num=map(str, input().split())
    if t=="S": card[0][int(num)-1] += 1
    elif t=="H": card[1][int(num)-1] += 1
    elif t=="C": card[2][int(num)-1] += 1
    elif t=="D": card[3][int(num)-1] += 1

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

Submission status: Accepted

Solution code:
n=int(input())

s=[True]*13
h=[True]*13
c=[True]*13
d=[True]*13

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

  if mark=='S':
    s[int(num)-1]=False
  if mark=='H':
    h[int(num)-1]=False
  if mark=='C':
    c[int(num)-1]=False
  if mark=='D':
    d[int(num)-1]=False

for i in range(0,13):
  if s[i]==True:
    print("S",i+1)
for i in range(0,13):
  if h[i]==True:
    print("H",i+1)
for i in range(0,13):
  if c[i]==True:
    print("C",i+1)
for i in range(0,13):
  if d[i]==True:
    print("D",i+1)

Submission status: Accepted

Solution code:
n = int(input())
card = [list(range(1,14)) for i in range(4)]
for i in range(n):
    a,b=input().split()
    if a == "S":
        card[0].remove(int(b))
    elif a ==  "H":
        card[1].remove(int(b))
    elif a ==  "C":
        card[2].remove(int(b))
    elif a ==  "D":
        card[3].remove(int(b))

for i in range(4):
    for j in card[i]:
        if i == 0:
            print("S",j)
        elif i == 1:
            print("H",j)
        elif i == 2:
            print("C",j)
        else:
            print("D",j)

Submission status: Accepted

Solution code:
tbl = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]

n = int(input())

for k in range(n):
    egara,suji = input().split()
    rank = int(suji)
    tbl [pattern.index(egara)][rank-1] = True

for i in range(4):
    for j in range(13):
        if tbl[i][j] == False:
            print(pattern[i],j+1)

Submission status: Accepted

Solution code:
S=[]
H=[]
C=[]
D=[]
n=int(input())
for i in range(n):
    a,b=map(str,input().split())
    if a=='S':
        S.append(int(b))
    if a=='H':
        H.append(int(b))
    if a=='C':
        C.append(int(b))
    if a=='D':
        D.append(int(b))
for i in range(1,14):
    if not (i in S):
        print(f'S {i}')
for i in range(1,14):
    if not (i in H):
        print(f'H {i}')
for i in range(1,14):
    if not (i in C):
        print(f'C {i}')
for i in range(1,14):
    if not (i in D):
        print(f'D {i}')

Submission status: Accepted

Solution code:
x=int(input())
list1=[1,2,3,4,5,6,7,8,9,10,11,12,13]
list2=[1,2,3,4,5,6,7,8,9,10,11,12,13]
list3=[1,2,3,4,5,6,7,8,9,10,11,12,13]
list4=[1,2,3,4,5,6,7,8,9,10,11,12,13]
for i in range(x):
    a,b=map(str,input().split())
    b=int(b)
    if a=="S":
        list1.remove(b)
    if a=="H":
        list2.remove(b)
    if a=="C":
        list3.remove(b)
    if a=="D":
        list4.remove(b)
for j in range(len(list1)):
    print("S",list1[j])
for j in range(len(list2)):
    print("H",list2[j])
for j in range(len(list3)):
    print("C",list3[j])
for j in range(len(list4)):
    print("D",list4[j])

Submission status: Accepted

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

for i in range(1,53):
    if i not in cards:
        print(suits[(i-1)//13],(i-1)%13+1)

Submission status: Accepted

Solution code:
# 太郎が花子と一緒にトランプ遊びをしようとしたところ、52枚あるはずのカードが n 枚のカードしか手元にありません。
# これらの n 枚のカードを入力として、足りないカードを出力するプログラムを作成して下さい。
# 太郎が最初に持っていたトランプはジョーカーを除く52枚のカードです。
# 52枚のカードは、スペード、ハート、クラブ、ダイヤの４つの絵柄に分かれており、各絵柄には13のランクがあります。


# coding: utf-8
# Your code here!
cards = {
    'S': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'H': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'C': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
    'D': ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
}

n = int(input())
for i in range(n):
    a = input().split()
    cards.get(a[0]).remove(a[1])
for key, values in cards.items():
    for value in values:
        print(key, value)

Submission status: Accepted

Solution code:
type=["S","H","C","D"]
ans=[[i,str(j)] for i in type for j in range(1,14,1)]

N=int(input())
for k in range(N):
    card=list(map(str, input().split()))
    ans.remove(card)

for l in range(52-N):
    print(*ans[l])

Submission status: Accepted

Solution code:
n = int(input())
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S","H","C","D"]
for i in range(n):
    ch,a = map(str,input().split())
    rank = int(a)
    cards[pattern.index(ch)][rank-1] = True
for i in range(4):
    for j in range(13):
        if cards[i][j] == False:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
used = [[False for i in range(13) ]for i in range(4)]
mark = "SHCD"
dic = {"S":0, "H":1, "C":2, "D":3}

n = int(input())
for i in range(n):
    li = input().split()
    m = li[0]
    k = int(li[1])
    
    used[dic[m]][k - 1] =True

for i in range(4):
    for j in range(13):
        if (not used[i][j]):
            print("{0} {1}".format(mark[i], j+1))

Submission status: Accepted

Solution code:
N, *S = open(0).read().split()
ss = set()
for i in range(0, len(S), 2):
    s = S[i]
    n = S[i+1]
    k = "{} {}".format(s, n)
    ss.add(k)

m = ["S", "H", "C", "D"]
for i in range(4):
    for j in range(13):
        k = "{} {}".format(m[i], j+1)
        if k not in ss:
            print(k)

Submission status: Accepted

Solution code:
n=int(input())
d={"S":[],"H":[],"C":[],"D":[]}

for i in range(n):
    m,num=input().split()
    d[m].append(num)

for x in d:
    for i in range(1,14):
        if not str(i) in d[x]:
            print("{} {}".format(x,i))

Submission status: Accepted

Solution code:
cards = [False for i in range(52)]
patterns = {"S":0, "H":1, "C":2, "D":3}
n = int(input())
count = 0
while count < n:
    data = input().split()
    card = int(data[1]) - 1
    cards[card + 13 * patterns[data[0]]] = True
    count += 1
for i in range(52):
    if cards[i] == False:
        row = list(patterns.keys())[list(patterns.values()).index(i // 13)]
        col = i % 13 + 1
        print(row, col)

Submission status: Accepted

Solution code:

n=int(input())
x=[1,2,3,4,5,6,7,8,9,10,11,12,13]
s=[]
h=[]
c=[]
d=[]
for i in range(n):
    egara,no=input().split()
    No=int(no)
    if egara=='S':
        s.append(No)
    elif egara=='H':
        h.append(No)
    elif egara=='C':
        c.append(No)
    elif egara=='D':
        d.append(No)
    
s.sort()
h.sort()
c.sort()
d.sort()

for j in range(4):
    if j==0:
        ls=set(x)^set(s)
        lslist=list(ls)
        for k in range(len(ls)):
            print('S',end=' ')
            print(lslist[k])
    elif j==1:
        lh=set(x)^set(h)
        lhlist=list(lh)
        for l in range(len(lh)):
            print('H',end=' ')
            print(lhlist[l])
    elif j==2:
        lc=set(x)^set(c)
        lclist=list(lc)
        for m in range(len(lc)):
            print('C',end=' ')
            print(lclist[m])
    elif j==3:
        ld=set(x)^set(d)
        ldlist=list(ld)
        for o in range(len(ld)):
            print('D',end=' ')
            print(ldlist[o])

Submission status: Accepted

Solution code:
C = [[i for i in range(1, 14)] for j in range(4)]
n = int(input())
for _ in range(n):
    m, n = input().split()
    if m == 'S':
        C[0].remove(int(n))
    elif m == 'H':
        C[1].remove(int(n))
    elif m == 'C':
        C[2].remove(int(n))
    elif m == 'D':
        C[3].remove(int(n))
for i, mrk in enumerate(['S', 'H', 'C', 'D']):
    for j in C[i]:
        print(mrk + ' ' + str(j))

Submission status: Accepted

Solution code:
n = int(input())
cardslist = []

for i in range(n):
    input_cards = input().split()
    cardslist.append(input_cards)

for mark in "SHCD":
    for i in range(1, 14):
        if [mark, str(i)] not in cardslist:
            print(mark + " " + str(i))

Submission status: Accepted

Solution code:
ranks = ["S", "H", "C", "D"]
cards = []
for rank in ranks:
    for i in range(1, 14, 1):
        cards.append([rank, str(i)])

n = int(input())
for i in range(n):
    x, y = map(str, input().split())

    for card in cards:
        if card[0] == x:
            if card[1] == y:
                cards.remove([x, y])

for card in cards:
    print(" ".join(card))

Submission status: Accepted

Solution code:
n = int(input())
cards = [[False for i in range(13)]for j in range(4)]
pattern = ["S","H","C","D"]
for i in range(n):
    p,num = [x for x in input().split()]
    num = int(num)
    cards[pattern.index(p)][num-1] = True
for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(pattern[i],j+1)

Submission status: Accepted

Solution code:
ans = [f'{s} {i}' for s in 'SHCD' for i in range(1,14)]
n = int(input())
for i in range(n):
    ans.remove(input())
for s in ans:
    print(s)

Submission status: Accepted

Solution code:
n = int(input())
s = [0] * 13
h = [0] * 13
c = [0] * 13
d = [0] * 13
deck = [s,h,c,d]
for _ in range(n):
    suit, num = input().split()
    num = int(num)
    if suit == "S":
        deck[0][num-1] = 1
    elif suit == "H":
        deck[1][num-1] = 1
    elif suit == "C":
        deck[2][num-1] = 1
    else:
        deck[3][num-1] = 1
for i in range(4):
    for num, x in enumerate(deck[i]):
        if x == 0:
            if i == 0:
                print(f"S {num+1}")
            if i == 1:
                print(f"H {num+1}")
            if i == 2:
                print(f"C {num+1}")
            if i == 3:
                print(f"D {num+1}")

Submission status: Accepted

Solution code:
s = [1] * 13
h = [1] * 13
c = [1] * 13
d = [1] * 13

n = int(input())
for _ in range(n):
    a, b = input().split()
    b = int(b)
    if a == "S":
        s[b - 1] = 0
    elif a == "H":
        h[b - 1] = 0
    elif a == "C":
        c[b - 1] = 0
    else:
        d[b - 1] = 0

for i in range(13):
    if s[i]:
        print(f"S {i+1}")
for i in range(13):
    if h[i]:
        print(f"H {i+1}")
for i in range(13):
    if c[i]:
        print(f"C {i+1}")
for i in range(13):
    if d[i]:
        print(f"D {i+1}")

Submission status: Accepted

Solution code:
cards_available = {}
for suit in (['S ', 'H ', 'C ', 'D ']):
    for num in range(1,14):
        s = suit + str(num)
        cards_available[s] = False

n = int(input())
for i in range(n):
    s = input()
    cards_available[s] = True

nalist = [k for k, v in cards_available.items() if v == False]
for card in nalist:
    print(card)

Submission status: Accepted

Solution code:
n = int(input())
cards = [[False for i in range(13)] for j in range(4)]
pattern = ["S", "H", "C", "D"]

for _ in range(n):
    ch, rank = input().split()
    cards[pattern.index(ch)][int(rank)-1] = True

for i in range(4):
    for j in range(13):
        if not cards[i][j]:
            print(pattern[i], j+1)

Submission status: Accepted

Solution code:
data_1 = [f'{s} {i}' for s in "SHCD" for i in range(1, 14)]
data_2 = []
n = int(input())
for x in range(1, n+1):
    y = input()
    data_2.append(y)
data_3 = []
for z in data_1 :
    if z not in data_2 :
        data_3.append(z)
for i in data_3 :
    print(i)