n = gets.to_i

spade, heart, club, diamond = [], [], [], []
suits = ["S", "H", "C", "D"]
num = 1..13

n.times do |i|
  suit, number = gets.split
  case suit 
  when suits[0]
  	spade << number.to_i
  when suits[1]
    heart << number.to_i
  when suits[2]
  	club << number.to_i
  when suits[3]
  	diamond << number.to_i
  end
end

all = [spade, heart, club, diamond]

# ????????????
all.each.with_index do |nums, i|
  nums.sort
  num.each do |element|
    if nums.include? element then
      puts "#{suits[i]} #{element}"
    end
  end
end