D = %w/D C H S/.product(%w/A 2 3 4 5 6 7 8 9 10 J Q K/).map {|(suit,num)| suit + num } I = 52.times.each_with_object({}) do |i,o| o[D[i]] = i end n = gets.to_i puts gets.split.sort {|a,b| I[a] <=> I[b]}.join(' ')