num=gets.to_i
i=1
cards = Hash.new{|h,k| h[k] = [] }
while i <= num
symbol, numeric = gets.chomp.split
cards[symbol] << numeric.to_i
i += 1
end

shortage = Hash.new{|h,k| h[k] = [] }
cards["S"].sort!
cards["H"].sort!
cards["C"].sort!
cards["D"].sort!

while i <= num
  if cards[symbol] == ""
    shortage[symbol] << i
  end    
    i += 1
end

puts shortage