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:
grp = ["S", "H", "C", "D"]
cards = []
for g in grp:
	for i in xrange(1, 13+1):
		cards.append("{0} {1}".format(g, i))
n = int(raw_input())
for i in xrange(n):
	card = raw_input()
	cards.remove(card)
for card in cards:
	print card

Submission status: Accepted

Solution code:
n = input()
r = range(0,52)
for i in range(0,n):
	x = map(str,raw_input().split(" "))
	y = (int(x[1])-1)/13
	if x[0] == "S":
		y = 0
	elif x[0] == "H":
		y = 1
	elif x[0] =="C":
		y = 2
	else:
		y = 3
	z = (int(x[1])-1)
	r.remove(y*13+z)
s = "S"
for j in range(0,len(r)):
	y = r[j]/13
	z = r[j]%13
	if y ==1:
		s = "H"
	elif y ==2:
		s = "C"
	elif y ==3:
		s ="D"
	print s+" "+str(z+1)

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:
n = input()
card = []
for i in range(n):
    card.append(raw_input())

for a in ['S','H','C','D']:
    for b in range(1,14):
        check = a +  " " + str(b)
        for c in card:
            if check == c:
                flg = 0
                break
            else:
                flg = 1
        if flg == 1:
            print check

Submission status: Accepted

Solution code:
num = int(raw_input())
list_ = [[False for i in range(13)] for j in range(4)]
for x in range(0, num):
	mark, number = map(str, raw_input().split())
	if mark == 'S':
		list_[0][int(number) - 1] = True
	if mark == 'H':
		list_[1][int(number) - 1] = True
	if mark == 'C':
		list_[2][int(number) - 1] = True
	if mark == 'D':
		list_[3][int(number) - 1] = True

for x in range(0, 4):
	for y in range(0, 13):
		if not list_[x][y]:
			if x == 0:
				print "S", y + 1
			elif x == 1:
				print "H", y + 1
			elif x == 2:
				print "C", y + 1
			else:
				print "D", y + 1

Submission status: Accepted

Solution code:
import sys

SUITS = ['S', 'H', 'C', 'D']
exist_cards = {suit:[] for suit in SUITS}

n = input()

for line in sys.stdin:
    suit, number = line.split()
    exist_cards[suit].append(int(number))


for suit in SUITS:
    for i in range(1, 14):
        if i not in exist_cards[suit]:
            print(suit, i)

Submission status: Accepted

Solution code:
import sys

SUITS = ('S', 'H', 'C', 'D')
cards = {suit:{i for i in range(1, 14)} for suit in SUITS}

n = input() # 読み捨て

for line in sys.stdin:
    suit, number = line.split()
    cards[suit].discard(int(number))

for suit in SUITS:
    for i in cards[suit]:
        print(suit, i)

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1,14)],
        'H': [int(x) for x in range(1,14)],
        'C': [int(x) for x in range(1,14)],
        'D': [int(x) for x in range(1,14)]
        }

count = int(input())

for c in range(count):
    (s, r) = input().split()
    r = int(r)

    del data[s][data[s].index(r)]


for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1,14)],
        'H': [int(x) for x in range(1,14)],
        'C': [int(x) for x in range(1,14)],
        'D': [int(x) for x in range(1,14)],
        }

count = int(input())

for c in range(count):
    (s, r) = input().split()
    r = int(r)
    del data[s][data[s].index(r)]


for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1, 14)],
        'H': [int(x) for x in range(1, 14)],
        'C': [int(x) for x in range(1, 14)],
        'D': [int(x) for x in range(1, 14)]
        }

count = int(input())

for c in range(count):
    (s,r) = input().split()
    r = int(r)
    del data[s][data[s].index(r)]
        
for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1,14)],
        'H': [int(x) for x in range(1,14)],
        'C': [int(x) for x in range(1,14)],
        'D': [int(x) for x in range(1,14)],
        }

count = int(input())

for c in range(count):
    (s, r) = input().split()
    r = int(r)
    del data[s][data[s].index(r)]

for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
import sys

n = input()
a = [] 
flag = {}
for j in range(1, 14):
    flag[('S',j)] = 0
    flag[('H',j)] = 0
    flag[('C',j)] = 0
    flag[('D',j)] = 0

for i in range(n):
    temp = map(str, raw_input().split())
    a.append((temp[0],temp[1]))
    #print a[i][0]
    #print a[i][1]

card = ['S', 'H', 'C', 'D']
#print card

for egara in card:
    for i in range(n):
        if(a[i][0] == egara):
            for j in range(1,14):
                if(int(a[i][1]) == j):
                    flag[(egara, j)] = 1

for egara in card:
    for j in range(1,14):
        if(flag[(egara, j)] == 0):
            sys.stdout.write(egara)
            sys.stdout.write(' ')
            sys.stdout.write(str(j))
            print

exit(0)

Submission status: Accepted

Solution code:
NumberOfSheet = int(input())
OwnedCards = [[str(i) for i in input().split()] for loop in range(NumberOfSheet)]
S = [int(0) for i in range(13)]
H = [int(0) for i in range(13)]
C = [int(0) for i in range(13)]
D = [int(0) for i in range(13)]
for i in OwnedCards:
  if i[0] == 'S' or i[0] == 'H' or i[0] == 'C' or i[0] == 'D':
    if i[0] == 'S': S[int(i[1]) - 1] = 1
    if i[0] == 'H': H[int(i[1]) - 1] = 1
    if i[0] == 'C': C[int(i[1]) - 1] = 1
    if i[0] == 'D': D[int(i[1]) - 1] = 1

for i in range(13):
  if S[i] == 0: print('S',i + 1)
for i in range(13):
  if H[i] == 0: print('H',i + 1)
for i in range(13):
  if C[i] == 0: print('C',i + 1)
for i in range(13):
  if D[i] == 0: print('D',i + 1)

Submission status: Accepted

Solution code:
cards = {
    'S':[r for r in range(1,13+1)],
    'H':[r for r in range(1,13+1)],
    'C':[r for r in range(1,13+1)],
    'D':[r for r in range(1,13+1)]
}

n = int(input())
for nc in range(n):
    (s,r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S','H','C','D']:
    for r in cards[s]:
            print(s,r)

Submission status: Accepted

Solution code:
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }

n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

Solution code:
cards = {
        'S': [r for r in range(1, 13+1)],
        'H': [r for r in range(1, 13+1)],
        'C': [r for r in range(1, 13+1)],
        'D': [r for r in range(1, 13+1)]
        }

n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

Solution code:
cards = {
        'S':[r for r in range(1,13+1)],
        'H':[r for r in range(1,13+1)],
        'C':[r for r in range(1,13+1)],
        'D':[r for r in range(1,13+1)],
        }

n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

Solution code:
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }
 
n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]
 
for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

Solution code:
import sys
n = int(sys.stdin.readline())

cards = {"S": [], "H": [], "C": [], "D": []}
for line in sys.stdin:
    (suit, number) = line.split()
    cards[suit].append(int(number))

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

Submission status: Accepted

Solution code:
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }
n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]

for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

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

for k in pat:
    for j in rank:
        dic[(k,j)]=0

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

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

Submission status: Accepted

Solution code:
x = input()
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]
for i in range(x):
	mark, num = map(str, raw_input().split())
	if mark == 'S':
		S.remove(int(num))
	elif mark == 'H':
		H.remove(int(num))
	elif mark == 'C':
		C.remove(int(num))
	elif mark == 'D':
		D.remove(int(num))
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: Accepted

Solution code:
import sys

def to_str(symbol, num):
    return '{0} {1}'.format(symbol, num)

if __name__ == '__main__':
    symbols = ['S','H','C','D']
    cards = [to_str(x,y) for x in symbols for y in range(1,14)]
    n = int(input())
    if n == 52: sys.exit()
    for i in range(n):
        cards.remove(input())
    print('\n'.join(cards))

Submission status: Accepted

Solution code:
#coding:utf-8
#1_6_B 2015.4.5
suits = ['S','H','C','D']
cards = {suit:[i for i in range(1,14)] for suit in suits}

n = int(input())
for i in range(n):
    suit,rank = input().split()
    cards[suit].remove(int(rank))

for suit in suits:
    for i in cards[suit]:
        print(suit,i)

Submission status: Accepted

Solution code:
n=input();a=[];b="SHCD"
for i in range(4*13):a.append(b[i/13]+" "+str(i%13+1))
for i in range(n):a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
a=[];b="SHCD"
for i in range(4*13):a.append(b[i/13]+" "+str(i%13+1))
for i in range(input()):a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
a=[]
for i in range(4*13):a.append("SHCD"[i/13]+" "+str(i%13+1))
for i in range(input()):a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
a=[]
for i in range(52):a.append("SHCD"[i/13]+" "+str(i%13+1))
for i in range(input()):a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
a=[]
for i in range(4*13):a.append("SHCD"[i/13]+" "+str(i%13+1))
for i in range(4*13):pass

for i in range(input()):a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
a=[];i=52;j=input()
while i:i-=1;a.append("DCHS"[i/13]+" "+str(13-i%13))
while j:j-=1;a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
j=input();i=52;a=[""]*i
while i:i-=1;a[i]="SHCD"[i/13]+" "+str(i%13+1)
while j:j-=1;a.remove(raw_input())
for i in a:print i

Submission status: Accepted

Solution code:
n=int(input())
data={
	'S':[int(x) for x in range(1,14)],
	'H':[int(x) for x in range(1,14)],
	'C':[int(x) for x in range(1,14)],
	'D':[int(x) for x in range(1,14)]
	}
	

for i in range(0,n):
	s,r=input().split()
	r=int(r)
	data[s].remove(r)

for i in('S','H','C','D'):
	for v in data[i]:
		print(i,v)

Submission status: Accepted

Solution code:
import sys

n = int( sys.stdin.readline() )
s = [ False ] * 13
h = [ False ] * 13
c = [ False ] * 13
d = [ False ] * 13
for i in range( 0, n ):
	pattern, num = sys.stdin.readline().split( " " )
	if "S" == pattern:
		s[ int( num )-1 ] = True
	elif "H" == pattern:
		h[ int( num )-1 ] = True
	elif "C" == pattern:
		c[ int( num )-1 ] = True
	elif "D" == pattern:
		d[ int( num )-1 ] = True

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

Submission status: Accepted

Solution code:
import sys

n = int( sys.stdin.readline() )
cards = { 'S': [ False ] * 13, 'H': [ False ] * 13, 'C': [ False ] * 13, 'D': [ False ] * 13 }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	if "S" == pattern:
		cards[ 'S' ][ int( num )-1 ] = True
	elif "H" == pattern:
		cards[ 'H' ][ int( num )-1 ] = True
	elif "C" == pattern:
		cards[ 'C' ][ int( num )-1 ] = True
	elif "D" == pattern:
		cards[ 'D' ][ int( num )-1 ] = True

for pattern in ( 'S', 'H', 'C', 'D' ):
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Submission status: Accepted

Solution code:
import sys

n = int( sys.stdin.readline() )
cards = { 'S': [ False ] * 13, 'H': [ False ] * 13, 'C': [ False ] * 13, 'D': [ False ] * 13 }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	cards[ pattern ][ int( num )-1 ] = True

for pattern in ( 'S', 'H', 'C', 'D' ):
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Submission status: Accepted

Solution code:
import sys

n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in ( 'S', 'H', 'C', 'D' ) }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	cards[ pattern ][ int( num )-1 ] = True

for pattern in ( 'S', 'H', 'C', 'D' ):
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Submission status: Accepted

Solution code:
import sys

patterns = ( 'S', 'H', 'C', 'D' )
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in patterns }
for i in range( n ):
	pattern, num = sys.stdin.readline().split( " " )
	cards[ pattern ][ int( num )-1 ] = True

for pattern in patterns:
	for i in range( 13 ):
		if not cards[ pattern ][ i ]:
			print( "{:s} {:d}".format( pattern, i+1 ) )

Submission status: Accepted

Solution code:
suit = ['S', 'H', 'C', 'D']
cards = [[i, j] for i in suit for j in map(str, range(1, 14))]
for i in range(input()):
    cards.remove(raw_input().split())
for i in cards:
    print i[0],i[1]

Submission status: Accepted

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

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

n = int(raw_input())

for i in xrange(n):
	symbol, num = map(str, raw_input().split())
	if symbol == 'S':
		S[int(num)-1] = 1
	elif symbol == 'H':
		H[int(num)-1] = 1
	elif symbol == 'C':
		C[int(num)-1] = 1
	else:
		D[int(num)-1] = 1

cards = [S, H, C, D]
marks = ['S', 'H', 'C', 'D']

for card, mark in zip(cards, marks):
	for index, num in enumerate(card):
		if num < 1:
			print mark, index+1

Submission status: Accepted

Solution code:
#coding:UTF-8

n = input()
arr = {'S':range(13),'H':range(13),'C':range(13),'D':range(13)}

for i in range(n):
    a,b = raw_input().split()
    b = int(b)
    arr[a][b-1] = 14

for j in ['S','H','C','D']:
    for k in range(13):
        if arr[j][k] == 14:
            continue
        print j+" "+str(k+1)

Submission status: Accepted

Solution code:
n = int(input())
cards = []
for i in range(n):
    s, r = input().strip().split()
    cards.append((s, int(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:
if __name__ == "__main__":
    n = int(raw_input())

    s = []
    h = []
    c = []
    d = []

    i = 0
    while i < n:
        v = raw_input().split()
        if v[0] == "S":
            s.append(int(v[1]))
        elif v[0] == "H":
            h.append(int(v[1]))
        elif v[0] == "C":
            c.append(int(v[1]))
        elif v[0] == "D":
            d.append(int(v[1]))
        i += 1

    i = 1
    while i <= 13:
       if i not in s:
           print "S {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in h:
           print "H {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in c:
           print "C {0}".format(i)
       i += 1

    i = 1
    while i <= 13:
       if i not in d:
           print "D {0}".format(i)
       i += 1

Submission status: Accepted

Solution code:
# coding=utf-8

n = int(raw_input())
cards = {'S':[], 'H':[], 'C':[], 'D':[]}
for _ in xrange(n):
    mark, num = raw_input().split()
    cards[mark].append(num)
for mark in ['S', 'H', 'C', 'D']:
    for i in xrange(1, 14):
        if str(i) not in cards[mark]:
            print mark + ' ' + str(i)

Submission status: Accepted

Solution code:
import collections

rank = {'S': 0, 'H': 1, 'C': 2, 'D': 3}
Card = collections.namedtuple('Card', ['suit', 'num'])
all_cards = {Card(suit, str(num)) for suit in ['S', 'H', 'C', 'D'] for num in range(1, 14)}

n = int(input())
cards = {Card(*input().split()) for _ in range(n)}
lost = sorted(all_cards - cards, key=lambda x: (rank[x.suit], int(x.num)))
if lost:
    print('\n'.join('%s %s' % (suit, num) for suit, num in lost))

Submission status: Accepted

Solution code:
n = int(raw_input())
card_list = 52*[0]

for i in range(0,n):
	(mark,rank) = map(str,raw_input().split())
	for j in range(0,4):
		if mark == 'SHCD'[j]:
			card_list[13*j+int(rank)-1] = 1

for i in range(0,52):
	if card_list[i] == 0:
		print '%c %d' %('SHCD'[i/13],i%13+1)

Submission status: Accepted

Solution code:
count = int(raw_input())
S = []
H = []
C = []
D = []

while count:
  arr = map(str, raw_input().split(" "))
  if arr[0] == "S":
    S.append(int(arr[1]))
  elif arr[0] == "H":
    H.append(int(arr[1]))
  elif arr[0] == "C":
    C.append(int(arr[1]))
  else:
    D.append(int(arr[1]))
  count -= 1

S.sort()
H.sort()
C.sort()
D.sort()

ans_s = []
ans_h = []
ans_c = []
ans_d = []

for x in range(1, 14):
  if not x in S:
    ans_s.append(x)
  if not x in H:
    ans_h.append(x)
  if not x in C:
    ans_c.append(x)
  if not x in D:
    ans_d.append(x)

def answer(arr, value):
  for x in arr:
    print "%s %s" % (value, str(x))

answer(ans_s, 'S')
answer(ans_h, 'H')
answer(ans_c, 'C')
answer(ans_d, 'D')

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1,14)],
        'H': [int(x) for x in range(1,14)],
        'C': [int(x) for x in range(1,14)],
        'D': [int(x) for x in range(1,14)]
        }
 
count = int(input())
 
for c in range(count):
    (s, r) = input().split()
    r = int(r)
 
    del data[s][data[s].index(r)]
 
 
for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
data = {
        'S': [int(x) for x in range(1,14)],
        'H': [int(x) for x in range(1,14)],
        'C': [int(x) for x in range(1,14)],
        'D': [int(x) for x in range(1,14)],
        }
 
count = int(input())
 
for c in range(count):
    (s, r) = input().split()
    r = int(r)
    del data[s][data[s].index(r)]
 
for i in ('S', 'H', 'C', 'D'):
    for v in data[i]:
        print(i, v)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in  range(n):
     (s, r) = input().split()
     cards[s][int(r) - 1] = 1

for s in('S','H','C','D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
 
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
	'S':[0 for _ in range(13)],
	'H':[0 for _ in range(13)],
	'C':[0 for _ in range(13)],
	'D':[0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
   
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
}
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1
    
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r + 1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range( 13)],
        'H': [0 for _ in range( 13)],
        'C': [0 for _ in range( 13)],
        'D': [0 for _ in range( 13)],
        }

n = int( input())
for _ in range( n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r

for s in ( 'S', 'H', 'C', 'D'):
    for r in range( 13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format( s, r+1))

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
 
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
 
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))

Submission status: Accepted

Solution code:
cards = {
        'S': [r for r in range(1,13+1)],
        'H': [r for r in range(1,13+1)],
        'C': [r for r in range(1,13+1)],
        'D': [r for r in range(1,13+1)],
        }
  
n = int(input())
for nc in range(n):
    (s, r) = input().split()
    index = cards[s].index(int(r))
    del cards[s][index]
  
for s in ['S', 'H', 'C', 'D']:
    for r in cards[s]:
        print(s, r)

Submission status: Accepted

Solution code:
cards = {
        'S':[0 for _ in range(13)],
        'H':[0 for _ in range(13)],
        'C':[0 for _ in range(13)],
        'D':[0 for _ in range(13)],
        }

n = int(input())
for _ in range(n):
    (s, r) = input().split()
    cards[s][int(r) - 1] = 1

for s in ['S','H','C','D']:
    for r in range(13):
        if cards[s][r] == 0:
            print(s, r+1)

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
  
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
  
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))

Submission status: Accepted

Solution code:
import sys
 
patterns = ( 'S', 'H', 'C', 'D' )
n = int( sys.stdin.readline() )
cards = { pattern:[False]*13 for pattern in patterns }
for i in range( n ):
    pattern, num = sys.stdin.readline().split( " " )
    cards[ pattern ][ int( num )-1 ] = True
 
for pattern in patterns:
    for i in range( 13 ):
        if not cards[ pattern ][ i ]:
            print( "{:s} {:d}".format( pattern, i+1 ) )

Submission status: Accepted

Solution code:
n = int(raw_input())

i = 0
s = []
h = []
c = []
d = []

def order_list(list):
  l = len(list)
  for i in xrange(l):
    j = i + 1
    while j < l:
      if list[i] > list[j]:
        temp = list[i]
        list[i] = list[j]
        list[j] = temp
      j += 1

  return list

def not_enough_cards(mark, list):
  list = order_list(list)
  # line = "########################################"
  # print line
  # print mark + ":"
  # print list
  # print line
  i = 0
  for x in xrange(1, 14):
    # print "x = " + str(x) + ", i = " + str(i)
    if i >= len(list):
      print mark + " " + str(x)
    elif x != list[i]:
      print mark + " " + str(x)
    else:
      i += 1

while i < n:
  line = raw_input().split(" ")
  line[1] = int(line[1])
  if line[0] == "S":
    s.append(line[1])
  elif line[0] == "H":
    h.append(line[1])
  elif line[0] == "C":
    c.append(line[1])
  elif line[0] == "D":
    d.append(line[1])
  i += 1

not_enough_cards("S", s)
not_enough_cards("H", h)
not_enough_cards("C", c)
not_enough_cards("D", d)

Submission status: Accepted

Solution code:
cards=[[i,j] for i in ['S','H','C','D'] for j in map(str,xrange(1,14))]
for i in xrange(int(raw_input())):
	cards.remove(raw_input().split())
for i in cards:
	print i[0],i[1]

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
   
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
   
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))

Submission status: Accepted

Solution code:
from itertools import product
(lambda *_: None)(
    *(lambda full, hand: map(print,
                             filter(lambda c: c not in hand, full)))(
        map(' '.join, product('SHCD', map(str, range(1, 14)))),
        set(map(lambda _: input(), range(int(input()))))))

Submission status: Accepted

Solution code:
total_card = []
for flower in 'SHCD':
    for num in range(1, 14):
        total_card.append((flower, num))

current_card = []
k = int(raw_input())
for i in range(k):
    f, v = map(str, raw_input().split())
    t = (f, int(v))
    current_card.append(t)


loss_card = []
for tu in total_card:
    if tu not in current_card:
        loss_card.append(tu)

for tu in loss_card:
    print tu[0] + ' ' + str(tu[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cards_num = int(input())

cards = []

missing_cards = []

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

for i in range(1, 14):
    if "S {0}".format(i) not in cards:
        missing_cards.append("S {0}".format(i))
for i in range(1, 14):
    if "H {0}".format(i) not in cards:
        missing_cards.append("H {0}".format(i))
for i in range(1, 14):
    if "C {0}".format(i) not in cards:
        missing_cards.append("C {0}".format(i))
for i in range(1, 14):
    if "D {0}".format(i) not in cards:
        missing_cards.append("D {0}".format(i))

for i in missing_cards:
    print(i)

Submission status: Accepted

Solution code:
n = input()
S = []
H = []
C = []
D = []
i = 1
while True:
    if i > n:
        break

    card = raw_input().split()
    mark = card[0]
    num = int(card[1])

    if mark == 'S':
        S.append(num)
    elif mark == 'H':
        H.append(num)
    elif mark == 'C':
        C.append(num)
    elif mark == 'D':
        D.append(num)

    i += 1

diff_S = set(range(1, 14)) - set(S)
for s in sorted(diff_S):
    print "S %d" % s
diff_H = set(range(1, 14)) - set(H)
for h in sorted(diff_H):
    print "H %d" % h
diff_C = set(range(1, 14)) - set(C)
for c in sorted(diff_C):
    print "C %d" % c
diff_D = set(range(1, 14)) - set(D)
for d in sorted(diff_D):
    print "D %d" % d

Submission status: Accepted

Solution code:
cards = {
        'S': [0 for _ in range(13)],
        'H': [0 for _ in range(13)],
        'C': [0 for _ in range(13)],
        'D': [0 for _ in range(13)],
        }
    
n = int(input())
for _ in range(n):
    (s, r) = input().split()
    r = int(r)
    cards[s][r - 1] = r
    
for s in ('S', 'H', 'C', 'D'):
    for r in range(13):
        if cards[s][r] == 0:
            print( '{0:s} {1:d}'.format(s, r+1))