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 = input()
s = []
h = []
c = []
d = []
for i in range(n):
	spare = raw_input().split()
	if spare[0]=='S':
		s.append(int(spare[1]))
	elif spare[0]=='H':
		h.append(int(spare[1]))
	elif spare[0]=='C':
		c.append(int(spare[1]))
	else :
		d.append(int(spare[1]))
for j in range(1,14):
	judge = True
	for k in range(len(s)):
		if j==s[k] :
			judge = False
			break
	if judge :
		print 'S %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(h)):
		if j==h[k] :
			judge = False
			break
	if judge :
		print 'H %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(c)):
		if j==c[k] :
			judge = False
			break
	if judge :
		print 'C %d' %j
for j in range(1,14):
	judge = True
	for k in range(len(d)):
		if j==d[k] :
			judge = False
			break
	if judge :
		print 'D %d' %j

Submission status: Accepted

Solution code:
import sys
n = input()
count = 0
Ss = []
Hs = []
Cs = []
Ds = []
while count<n:
    mark, num = raw_input().split()
    #num = int(num)
    if mark == 'S':
        Ss.append(num)
    elif mark == 'H':
        Hs.append(num)
    elif mark == 'C':
        Cs.append(num)
    elif mark == 'D':
        Ds.append(num)
    else :
        print "error"
        sys.exit()
    count+=1
for x in xrange(1,14):
    if str(x) not in Ss:
        print "S "+str(x)
for x in xrange(1,14):
    if str(x) not in Hs:
        print "H "+str(x)
for x in xrange(1,14):
    if str(x) not in Cs:
        print "C "+str(x)
for x in xrange(1,14):
    if str(x) not in Ds:
        print "D "+str(x)

Submission status: Accepted

Solution code:
n=input()
S=['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=['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=['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=['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']
cards=[S,H,C,D]
for i in range(n):
  exist=raw_input()
  if 'S' in exist:
    cards[0].remove(exist)
  if 'H' in exist:
    cards[1].remove(exist)
  if 'C' in exist:
    cards[2].remove(exist)
  if 'D' in exist:
    cards[3].remove(exist)
for j in range(4):
  for i in cards[j]:
    print i

Submission status: Accepted

Solution code:
card = {
	'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],
	}
dr = ['S','H','C','D']

n = int(raw_input())

for i in xrange(n):
	fffff,ddddd = map(str,raw_input().split())
	card[fffff].remove(int(ddddd))
	
for var in card:
	card[var].sort()
	
for var in dr:
	for i in xrange(len(card[var])):
		print var,card[var][i]

Submission status: Accepted

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

Submission status: Accepted

Solution code:
deck = [[0] * 13 for i in range(4)]
n = input()

for i in range(0, n) :
    suit, num = raw_input().split(" ")
    if (suit == "S") :
        deck[0][int(num)-1] = 1
    if (suit == "H") :
        deck[1][int(num)-1] = 1
    if (suit == "C") :
        deck[2][int(num)-1] = 1
    if (suit == "D") :
        deck[3][int(num)-1] = 1

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

Submission status: Accepted

Solution code:
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)
n = int(raw_input())
for i in range(0,n):
    input_line = raw_input().split()
    mark = input_line[0]
    num = int(input_line[1])
    if mark == "S":
        s.remove(num)
    elif mark == "H":
        h.remove(num)
    elif mark == "C":
        c.remove(num)
    elif mark == "D":
        d.remove(num)
for i in s:
    print "S " + str(i)
for i in h:
    print "H " + str(i)
for i in c:
    print "C " + str(i)
for i in d:
    print "D " + str(i)

Submission status: Accepted

Solution code:
deck = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 

n = input()

for i in range(0, n):
    suit, num = raw_input().split(" ")
    deck[suit][int(num)-1] = 1

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

Submission status: Accepted

Solution code:
suit = ['S','H','C','D']
num = range(0, 13)
deck = {'S':[0]*13, 'H':[0]*13, 'C':[0]*13, 'D':[0]*13} 

n = input()
 
for i in range(0, n):
    a, b = raw_input().split(" ")
    deck[a][int(b)-1] = 1
 
for i in suit:
    for j in num:
        if (deck[i][j] == 0):
            print("%s %d" % (i, j+1))

Submission status: Accepted

Solution code:
from collections import OrderedDict

cards = OrderedDict()
cards['S'] = set()
cards['H'] = set()
cards['C'] = set()
cards['D'] = set()

n = int(input())
for _ in range(n):
    suit, num = input().split()
    num = int(num)
    cards[suit].add(num)

for suit, nums in cards.items():
    for num in range(1,14):
        if num not in nums:
            print(suit, num)

Submission status: Accepted

Solution code:
from collections import defaultdict

trump = {
    'S': set(range(1, 14)),
    'H': set(range(1, 14)),
    'C': set(range(1, 14)),
    'D': set(range(1, 14)),
}
taro_trump = defaultdict(set)

n = int(input())
for i in range(n):
    (mark, num) = tuple(input().split(' '))
    num = int(num)
    taro_trump[mark].add(num)

no_taro_trump = defaultdict(set)
no_taro_trump['S'] = trump['S']
no_taro_trump['H'] = trump['H']
no_taro_trump['C'] = trump['C']
no_taro_trump['D'] = trump['D']

if 'S' in taro_trump:
    no_taro_trump['S'] = trump['S'] - taro_trump['S']
if 'H' in taro_trump:
    no_taro_trump['H'] = trump['H'] - taro_trump['H']
if 'C' in taro_trump:
    no_taro_trump['C'] = trump['C'] - taro_trump['C']
if 'D' in taro_trump:
    no_taro_trump['D'] = trump['D'] - taro_trump['D']

for mark in ['S', 'H', 'C', 'D']:
    for num in list(no_taro_trump[mark]):
        print(mark, num)

Submission status: Accepted

Solution code:
cards = {
		"S": [0 for n in range(13)],
		"H": [0 for n in range(13)],
		"C": [0 for n in range(13)],
		"D": [0 for n in range(13)]
}
t = int(input())
for n in range(t):
	a,b = input().split()
	cards[a][int(b)-1] = 1

for a in ("S", "H","C", "D"):
	for b in range(13):
		if cards[a][b] == 0:
			print(a,b+1)

Submission status: Accepted

Solution code:
# coding:utf-8

# ????????????
s = [False] * 13
# ?????????
h = [False] * 13 
# ?????????
c = [False] * 13
# ?????????
d = [False] * 13

T = {'S':s, 'H':h, 'C':c, 'D':d}

# ??\???
n = int(input())
for i in range(n):
    suit, num = input().split()
    num = int(num)
    T[suit][num-1] = True

for v in range(13):
    if not(T['S'][v]):
        print('S', v + 1)
for v in range(13):
    if not(T['H'][v]):
        print('H', v + 1)
for v in range(13):
    if not(T['C'][v]):
        print('C', v + 1)
for v in range(13):
    if not(T['D'][v]):
        print('D', v + 1)

Submission status: Accepted

Solution code:
num = int(input())

cards = list()

for i in range(num):
    cards.append(input())

pics = ['S', 'H', 'C', 'D']
nums = [str(i) for i in range(1, 14)]

for p in pics:
    for n in nums:
        c = p+' '+n
        if not c in cards:
            print(c)

Submission status: Accepted

Solution code:
n = int(input())
s = [n for n in range(1, 14)]
h = [n for n in range(1, 14)]
c = [n for n in range(1, 14)]
d = [n for n in range(1, 14)]
suits = ['S', 'H', 'C', 'D']
for i in range(n):
    x, y = [z for z in input().split()]
    y = int(y)
    if x == 'S':
        s[y - 1] = 0
    elif x == 'H':
        h[y - 1] = 0
    elif x == 'C':
        c[y - 1] = 0
    else:
        d[y - 1] = 0

data = [s, h, c, d]
for i in range(4):
    for x in data[i]:
        if x != 0:
            print(suits[i], str(x))

Submission status: Accepted

Solution code:
n = input()

S = [[0 for j in xrange(13)] for i in xrange(4)]
    
for i in xrange(n):
    tmp1, tmp2 = map(str, raw_input().split())
    if tmp1 == "S":
        S[0][int(tmp2) - 1] = 1
    elif tmp1 == "H":
        S[1][int(tmp2) - 1] = 1
    elif tmp1 == "C":
        S[2][int(tmp2) - 1] = 1
    elif tmp1 == "D":
        S[3][int(tmp2) - 1] = 1
        
for i in xrange(4):
    for j in xrange(13):
        if S[i][j] == 0:
            if i == 0:
                print "S",
            elif i == 1:
                print "H",
            elif i == 2:
                print "C",
            elif i == 3:
                print "D",
            print "%d" % (j + 1)

Submission status: Accepted

Solution code:
n = input()
a = []
c = []
for i in ['S ','H ','C ','D ']:
	for j in map(str,xrange(1,14)):
		a.append(i+j)
for i in xrange(n):
	a.remove(raw_input())
for i in xrange(len(a)):
	print a[i]

Submission status: Accepted

Solution code:
def CheckCards(Mark):
    for i in range(1, 14):
        if [Mark, i] not in Cards:
            print(Mark + " " + str(i))

n = int(input())
Cards = []
for i in range(n):
    Cards.append(input().split())
    Cards[i][1] = int(Cards[i][1])

CheckCards("S")
CheckCards("H")
CheckCards("C")
CheckCards("D")

Submission status: Accepted

Solution code:
n = input()
mark = ['S', 'H', 'C', 'D']
cards = ["{} {}".format(mark[i], j+1) for i in range(4) for j in range(13)]
for i in range(n):
    cards.remove(raw_input())
while len(cards) != 0:
    print cards.pop(0)

Submission status: Accepted

Solution code:
n = int(raw_input())
C = {'S':range(13), 'H':range(13), 'C':range(13), 'D':range(13)}

for i in range(n):
    suit, num = raw_input().split()
    num = int(num)
    C[suit][num-1] = 14

for i in ['S', 'H', 'C', 'D']:
    for j in range(13):
        if C[i][j] != 14:
            print "%s %d" %(i, j+1)

Submission status: Accepted

Solution code:
n = int(input())

cards = {

"S" : list(0 for q in range(13)),
"H" : list(0 for w in range(13)),
"C" : list(0 for e in range(13)),
"D" : list(0 for r in range(13)),

}

for _ in range(n):
	a,b = input().split()
	cards[a][int(b)-1] = 1
for a in ("S", "H", "C", "D"):
	for b in range(13):
		if cards[a][b] == 0:
			print(a,b+1)

Submission status: Accepted

Solution code:
n = input()
find = []
c = []
for i in ['S ','H ','C ','D ']:
    for j in map( str , xrange(1,14) ):
        find.append( i+j )   
for i in xrange(n):
    find.remove( raw_input() )
for i in xrange( len( find ) ):
    print find[i]

Submission status: Accepted

Solution code:
marks='SHCD'
n=input()
card=[raw_input().split() for _ in range(n)]
m={}
for mk,rk in card:
    m.setdefault(mk,[0]*14)
    m[mk][int(rk)]=1
for i in range(len(m)):
    k=marks[i]
    v=m[k]
    for j in range(1,14):
        if not v[j]: print k,j

Submission status: Accepted

Solution code:
Spades   = 0
Hearts   = 1
Clovers  = 2
Diamonds = 3
Cards = [[Spades, Hearts, Clovers, Diamonds] for j in range(13)]

for i in range(4):
    for j in range(13):
        Cards[j][i] = True

n = input()

for i in range(n):
    Input = raw_input().split()

    Numb = int(Input[1])
    if Input[0] == 'S':
        Mark = Spades
    if Input[0] == 'H':
        Mark = Hearts
    if Input[0] == 'C':
        Mark = Clovers
    if Input[0] == 'D':
        Mark = Diamonds

    Cards[Numb - 1][Mark] = False

for i in range(4):
    for j in range(13):
        if Cards[j][i]:
            if i == Spades:
                print 'S', j + 1
            if i == Hearts:
                print 'H', j + 1
            if i == Clovers:
                print 'C', j + 1
            if i == Diamonds:
                print 'D', j + 1

Submission status: Accepted

Solution code:
n=input()
  
s=range(1,14)
h=range(1,14)
c=range(1,14)
d=range(1,14)
   
for i in range(n):
   m, k=raw_input().split()
   if m == 'S':
      s[int(k)-1] = 0
   elif m == 'H':
      h[int(k)-1] = 0
   elif m == 'C':
      c[int(k)-1] = 0
   elif m == 'D':
      d[int(k)-1] = 0
  
for i in range(0, 13):
   if s[i] != 0:
      print 'S '+str(s[i])
  
for i in range(0, 13):
   if h[i] != 0:
      print 'H '+str(h[i])
  
for i in range(0, 13):
   if c[i] != 0:
      print 'C '+str(c[i])
  
for i in range(0, 13):
   if d[i] != 0:
      print 'D '+str(d[i])

Submission status: Accepted

Solution code:
n = int(raw_input())
s = range(1,14)
h = range(1,14)
c = range(1,14)
d = range(1,14)
 
for i in range(n):
    q,r = raw_input().split()
    if q == 'S':
        s[int(r)-1] = 0
    elif q == 'H':
        h[int(r)-1] = 0
    elif q == 'C':
        c[int(r)-1] = 0
    elif q == 'D':
        d[int(r)-1] = 0
 
a = 'S '
for i in range(13):
    if s[i] != 0:
        print a + str(s[i])
a = 'H '
for i in range(13):
    if h[i] != 0:
        print a + str(h[i])
a = 'C '
for i in range(13):
    if c[i] != 0:
        print a + str(c[i])
a = 'D '
for i in range(13):
    if d[i] != 0:
        print a + str(d[i])

Submission status: Accepted

Solution code:
S = [0] * 13
H = [0] * 13
C = [0] * 13
D = [0] * 13

SUIT = {}
SUIT['S'] = S
SUIT['H'] = H
SUIT['C'] = C
SUIT['D'] = D

n = input()
for _ in xrange(n):
    line = raw_input().split()
    (SUIT[line[0]])[int(line[1]) - 1] = 1

for suit in ['S', 'H', 'C', 'D']:
    for i in xrange(13):
        if (SUIT[suit])[i] == 0:
            print '%s %d' % (suit, i + 1)

Submission status: Accepted

Solution code:
n = int(raw_input())
s = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
h = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
c = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]
d = [0,0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in range(n):
    x = raw_input().split()
    x[1] = int(x[1])
    if x[0] == "S":
        s[x[1]] = 1
    elif x[0] == "H":
        h[x[1]] = 1
    elif x[0] == "C":
        c[x[1]] = 1
    elif x[0] == "D":
        d[x[1]] = 1

for i in range(1,14):
    if s[i] != 1:
        print "S %d" %i
for i in range(1,14):
    if h[i] != 1:
        print "H %d" %i
for i in range(1,14):
    if c[i] != 1:
        print "C %d" %i
for i in range(1,14):
    if d[i] != 1:
        print "D %d" %i

Submission status: Accepted

Solution code:
n=input()
c=[]
A=[]
for i in ['S ','H ','C ','D ']:
    for j in map(str,range(1,14)):
        A.append(i+j)   
for i in range(n):
    A.remove(raw_input())
for i in range(len(A)):
    print A[i]

Submission status: Accepted

Solution code:
n = int(raw_input())
temp = ''
S = ['S']
D = ['D']
H = ['H']
C = ['C']

for i in range(n):
    temp = str(raw_input())
    if temp[0] == 'S':
        S.append(temp)
    elif temp[0] == 'H':
        H.append(temp)
    elif temp[0] == 'C':
        C.append(temp)
    elif temp[0] == 'D':
        D.append(temp)

def find(X):
    frag = 0
    for i in range(1, 14):
        for j in range(1, len(X)):
            if X[j] == X[0][0] + ' ' + str(i):
                frag = 1
                break
        if frag == 0:
            print X[0][0] + ' ' + str(i)
        frag = 0

find(S)
find(H)
find(C)
find(D)

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code !

n = input()

A = []
for i in range(n):
    A.append(raw_input().split())
    
s = []
h = []
c = []
d = []  # mark???????????????
for i in range(n):
    if A[i][0] == 'S' :
        s.append(int(A[i][1]))
    elif A[i][0] == 'H':
        h.append(int(A[i][1]))
    elif A[i][0] == 'C':
        c.append(int(A[i][1]))
    elif A[i][0] == 'D':
        d.append(int(A[i][1]))

for i in range(1,14): #1-13?????§?????????
    judge = True
    for j in range(len(s)): 
        if i == s[j] :
            judge = False
            break
    if judge :    
        print "S",i
for i in range(1,14): #1-13?????§?????????
    judge = True
    for j in range(len(h)): 
        if i == h[j] :
            judge = False
            break
    if judge :    
        print "H",i
for i in range(1,14): #1-13?????§?????????
    judge = True
    for j in range(len(c)): 
        if i == c[j] :
            judge = False
            break
    if judge :    
        print "C",i
for i in range(1,14): #1-13?????§?????????
    judge = True
    for j in range(len(d)): 
        if i == d[j] :
            judge = False
            break
    if judge :    
        print "D",i

Submission status: Accepted

Solution code:
n = input()
S = ['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 = ['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 = ['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 = ['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']
cards=[S,H,C,D]

for i in range(n):
  exist = raw_input()
  if 'S' in exist:
    cards[0].remove(exist)
  if 'H' in exist:
    cards[1].remove(exist)
  if 'C' in exist:
    cards[2].remove(exist)
  if 'D' in exist:
    cards[3].remove(exist)

for j in range(4):
  for i in cards[j]:
    print i

Submission status: Accepted

Solution code:
n = input()
#a,b = map(str,raw_input().split())
a = [raw_input() for i in range(n)]
j=0
for i in range(1,14):
  for j in range(n):
    if a[j] == 'S %s' % i:
      break
    elif j==n-1:
      print 'S %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'H %s' % i:
      break
    elif j==n-1:
      print 'H %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'C %s' % i:
      break
    elif j==n-1:
      print 'C %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'D %s' % i:
      break
    elif j==n-1:
      print 'D %s' % i

Submission status: Accepted

Solution code:
n = input()
a = [raw_input() for i in range(n)]
j=0
for i in range(1,14):
  for j in range(n):
    if a[j] == 'S %s' % i:
      break
    elif j==n-1:
      print 'S %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'H %s' % i:
      break
    elif j==n-1:
      print 'H %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'C %s' % i:
      break
    elif j==n-1:
      print 'C %s' % i
for i in range(1,14):
  for j in range(n):
    if a[j] == 'D %s' % i:
      break
    elif j==n-1:
      print 'D %s' % i

Submission status: Accepted

Solution code:
n = int(raw_input())

card = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
 
for i in range(n):
  mark, nums = raw_input().split()
  card[mark][int(nums)-1] = 1
 
for i in ["S", "H", "C", "D"]:
  for j in range(13):
    if card[i][j] == 0:
      print "%s %d" % (i, j+1)

Submission status: Accepted

Solution code:
S = []
H = []
C = []
D = []

n = int(input())
for i in range(n):
    mark, num = [x for x in input().split()]
    if mark == 'S':
        S.append(int(num))

    elif mark == 'H':
        H.append(int(num))

    elif mark == "C":
        C.append(int(num))

    else: #D
        D.append(int(num))


for i in range(1,14):
    if not i in S:
        print("S", i)
for i in range(1,14):
    if not i in H:
        print("H", i)
for i in range(1,14):
    if not i in C:
        print("C", i)
for i in range(1,14):
    if not i in D:
        print("D", i)

Submission status: Accepted

Solution code:
n = int(raw_input())

list_cards = [0 for i in range(53)]

for i in range(1, n + 1):
    Type, Number = raw_input().split()
    Number = int(Number)
    if Type == "S":
        x = 0
    elif Type == "H":
        x = 1
    elif Type == "C":
        x = 2
    elif Type == "D":
        x = 3
    list_cards[x * 13 + Number] = 1
    
for i in range(1, 53):
    if list_cards[i] == 0:
        if 0 < i and i < 14:
            Type = "S"
        elif 13 < i and i < 27:
            Type = "H"
        elif 26 < i and i < 40:
            Type = "C"
        elif 39 < i and i < 53:
            Type = "D"
    
        d = i % 13
        if d == 0:
            d = 13
        if Type == "S":
            print "S %d" %(d)
        elif Type == "H":
            print "H %d" %(d)
        elif Type == "C":
            print "C %d" %(d)
        elif Type == "D":
            print "D %d" %(d)

Submission status: Accepted

Solution code:
n = input()
data = []
space = []
for i in ['S ', 'H ', 'C ', 'D ']:
    for j in map( str , xrange(1, 14)):
        data.append(i + j)   
for i in xrange(n):
    data.remove(raw_input())
for i in xrange(len(data)):
    print data[i]

Submission status: Accepted

Solution code:
z = input()
d = {}
c = 0
 
L = ['S','H','C','D']
for i in L:
    for j in range(1,14):
        d[i] = d.get(i,[]) + [j]
 
 
while c < z:
    x = raw_input().split()
    d[x[0]].remove(int(x[1]))
    c += 1
 
 
for i in L:
    for j in sorted(d[i]):
        print i + " " + str(j)

Submission status: Accepted

Solution code:
S =[i+1 for i in xrange(13)]
H =[i+1 for i in xrange(13)]
C =[i+1 for i in xrange(13)]
D =[i+1 for i in xrange(13)]
#[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

n = input()
for i in xrange(n):
    c, a = raw_input().split()
    if c == "S":
        for j in xrange(len(S)): 
            if S[j-1] == int(a):
             del S[j-1]
    elif c == "H":
        for j in xrange(len(H)): 
            if H[j-1] == int(a):
             del H[j-1]      
    elif c == "C":
        for j in xrange(len(C)): 
            if C[j-1] == int(a):
             del C[j-1]      
    elif c == "D":
        for j in xrange(len(D)): 
            if D[j-1] == int(a):
             del D[j-1]

for i in xrange(len(S)):
    print "S " + str(S[i])
    
for i in xrange(len(H)):
    print "H " + str(H[i])    
    
for i in xrange(len(C)):
    print "C " + str(C[i])    
    
for i in xrange(len(D)):
    print "D " + str(D[i])

Submission status: Accepted

Solution code:
deck = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
 
n = input()
 
for i in range(0, n):
    suit, num = raw_input().split(" ")
    deck[suit][int(num)-1] = 1
 
for i in ["S", "H", "C", "D"]:
    for j in range(0, 13):
        if (deck[i][j] == 0):
            print("%s %d" % (i, j+1))

Submission status: Accepted

Solution code:
n = int(raw_input())
 
c = {"S":[0]*13, "H":[0]*13, "C":[0]*13, "D":[0]*13} 
  
for i in range(n):
  mark, num = raw_input().split()
  c[mark][int(num)-1] = 1
  
for k in ["S", "H", "C", "D"]:
  for j in range(13):
    if c[k][j] == 0:
      print "%s %d" % (k, j+1)

Submission status: Accepted

Solution code:
cards = {

"S" : [0 for i in range(13)],
"H" : [0 for i in range(13)],
"C" : [0 for i in range(13)],
"D" : [0 for i in range(13)]
}

n = int(input())
for i in range(n):
	a,b = input().split()
	cards[a][int(b)-1] = 1

for a in ("S","H","C","D"):
	for b in range(13):
		if cards[a][b] == 0:
			print(a,b+1)

Submission status: Accepted

Solution code:
n=input()
S=['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=['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=['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=['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']
cards=[S,H,C,D]
for i in range(n):
  cardlist=raw_input()
  if 'S' in cardlist:
    cards[0].remove(cardlist)
  if 'H' in cardlist:
    cards[1].remove(cardlist)
  if 'C' in cardlist:
    cards[2].remove(cardlist)
  if 'D' in cardlist:
    cards[3].remove(cardlist)
for j in range(4):
  for i in cards[j]:
    print i

Submission status: Accepted

Solution code:
#coding: UTF-8

x = int(input())
a = 0
s = 0
h = 0
c = 0
d = 0
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listh = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listc = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
listd = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]

while a < x:
	l = raw_input().split()
	a += 1
	m = l[0]
	n = int(l[1])
	
	if m == "S":
		s += 1
		lists.remove(n)
	if m == "H":
		h += 1
		listh.remove(n)
	if m == "C":
		c += 1
		listc.remove(n)
	if m == "D":
		d += 1
		listd.remove(n)

for ss in lists:
	print "S %d"%ss
for hh in listh:
	print "H %d"%hh
for cc in listc:
	print "C %d"%cc
for dd in listd:
	print "D %d"%dd

Submission status: Accepted

Solution code:
n = int(input())
cards = []
for i in range(n):
	s,r=input().split()
	cards.append((s,int(r)))
for s,r in [(s,r) for s in 'SHCD' for r in range(1,14) if (s,r) not in cards]:
	print(s,r)

Submission status: Accepted

Solution code:

x = input()
mark = []
num = []
for i in xrange(x):
    inp = raw_input().split()
    inp[1] = int(inp[1])
    mark.append(inp)

trump = ["S","H","C","D"]
for i in xrange(4):
    for j in xrange(13):
        tako = [str(trump[i]), int(j + 1)]
        p = len(mark)
        for k in range(p):
            if tako == mark[k]:
                del mark[k]
                break
            if k == (p - 1):
                mark.append(tako)
for i in xrange(len(mark)):
    print mark[i][0], mark[i][1]

Submission status: Accepted

Solution code:
n = int(input())
my_cards = {input() for _ in range(n)}
lost_cards = (
  "{} {}".format(s, i)
  for s in ('S', 'H', 'C', 'D')
  for i in range(1, 13 + 1)
  if "{} {}".format(s, i) not in my_cards
)
for card in lost_cards:
  print (card)

Submission status: Accepted

Solution code:
def find_card(mark,input,result):
    for i in xrange(13):
        if input[i] == 0:
            result.append(i)
    result.sort()
    for x in result:
        print mark + " " +  str(x+1)

n = input()
s = [0]*13
h = [0]*13
c = [0]*13
d = [0]*13
for i in xrange(n):
    m,n = map(str,raw_input().split())
    n = int(n)-1
    if m in "S" :
        s[n] = 1
    elif m in "H":
        h[n] = 1
    elif m in "C":
        c[n] = 1
    elif m in "D":
        d[n] = 1

res_s=[]
res_h=[]
res_c=[]
res_d=[]

find_card("S",s,res_s)
find_card("H",h,res_h)
find_card("C",c,res_c)
find_card("D",d,res_d)

Submission status: Accepted

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

dic = {}
pat = ['S', 'H', 'C', 'D']
rank = [k for k in range(1, 14)]

#   dic?????????
for p in pat:
    for r in rank:
        dic[(p, r)] = 0

n = input()
for i in range(n):
    l = map(str, raw_input().split())
    p = l[0]
    r = int(l[1])
    dic[(p, r)] += 1

for p in pat:
    for r in rank:
        if dic[(p, r)] == 0:
            print "%s %d" %(p, r)

Submission status: Accepted

Solution code:
master = [(mark, number) for mark in ['S', 'H', 'C', 'D'] for number in range(1, 14)]
n = int(input())
cards = set()
for x in range(n):
    mark, number = input().split()
    cards.add((mark, int(number)))
lack = sorted((set(master) - cards), key = master.index)

for x in lack:
    print('%s %d' % x)

Submission status: Accepted

Solution code:
dic = {}
mark = ['S', 'H', 'C', 'D']
rank = [k for k in range(1, 14)]

for i in mark:
	for j in rank:
		dic[(i,j)] = 0

n = int(raw_input())
for k in range(n):
	p,r = raw_input().split()
	r = int(r)
	dic [(p,r)] += 1

for i in mark:
	for j in rank:
		if dic[(i,j)] == 0:
			print '%s %d' % (i,j)

Submission status: Accepted

Solution code:
n = input()
d_s = {}
d_h = {}
d_c = {}
d_d = {}
for x in map(str, xrange(1, 14)):
    d_s[x] = 0 
    d_h[x] = 0 
    d_c[x] = 0 
    d_d[x] = 0 
for x in xrange(1, n+1):
    line = raw_input().split()
    if line[0]=='S':
        d_s[line[1]] = 1
    elif line[0]=='H':
        d_h[line[1]] = 1
    elif line[0]=='C':
        d_c[line[1]] = 1
    else:
        d_d[line[1]] = 1
d_key = ['S', 'H', 'C', 'D']
d_all = {d_key[0]: d_s, d_key[1]: d_h, d_key[2]: d_c, d_key[3]: d_d} 
for shcd in d_key:
    for rank in xrange(1, 14):
        if d_all[shcd][str(rank)]==0:
            print '%s %s' % (shcd, rank)

Submission status: Accepted

Solution code:
n=int(input())
cs = [ (s,k) for s in ['S','H','C','D'] for k in range(1,14) ]
for _ in range(n):
    s,k=input().split()
    cs.remove((s,int(k)))
for (s, k) in cs:
    print(s, k)

Submission status: Accepted

Solution code:

def havec(x_list, y):
    x_list[y-1] = 1
    
def printc(x_list, s):
    for i in range(13):
        if x_list[i] == 0:
            print("%s %d" %(s, i+1))

n = input()
Sp = [0,0,0,0,0,0,0,0,0,0,0,0,0]
Ha = [0,0,0,0,0,0,0,0,0,0,0,0,0]
Cl = [0,0,0,0,0,0,0,0,0,0,0,0,0]
Di = [0,0,0,0,0,0,0,0,0,0,0,0,0]

for i in range(n):
    incard = raw_input()
    a, b = incard.split(" ")
    b = int(b)
    
    if a == "S":
        havec(Sp, b)
    elif a == "H":
        havec(Ha, b)
    elif a == "C":
        havec(Cl, b)
    else:
        havec(Di, b)

printc(Sp, "S")
printc(Ha, "H")
printc(Cl, "C")
printc(Di, "D")

Submission status: Accepted

Solution code:
n = input()
a = [raw_input() for _ in range(n)]
b = []
for i in ['S ','H ','C ','D ']:
    for j in range(1,14):
        b.append(i+str(j))
for i in a:
    b.remove(i)
for i in b:
    print i

Submission status: Accepted

Solution code:
class Card:
    def __init__(self, s, n):
        self.suit = s
        self.num = n

class FindingMissingCards:
    def __init__(self):
        self.allCards = []
        for s in ["S","H","C","D"]:
            for n in range(1,14):
                self.allCards.append(Card(s,n))
    def find(self, cards):
        for c in cards:
            for ac in self.allCards:
                if c.num == ac.num and c.suit == ac.suit:
                    self.allCards.remove(ac)
        for c in self.allCards:
            print "%s %d" % (c.suit, c.num)

if __name__ == "__main__":
    n = int(raw_input())
    cards = []
    for i in range(n):
        s, n = raw_input().split()
        cards.append(Card(s, int(n)))

    fmc = FindingMissingCards()
    fmc.find(cards)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(n):
	x, y = raw_input().split()
	d[x][int(y)-1] = True

for k in ["S","H","C","D"]:
	for i in range(13):
		if d[k][i]:
			continue
		print ("%s %d"%(k, i+1))

Submission status: Accepted

Solution code:
n = int(raw_input())
lst = []
#store all the cards
for i in ["S","H","C","D"]:
	for j in xrange(1,14):
		lst.append("{0} {1}".format(i,j))
#discard the given cards
for i in range(n):
	a = raw_input()
	lst.remove(a)
#print the result
for i in range(len(lst)):
	print lst[i]