("A".."C").map{|x| [x, gets.to_i]}.sort_by{|x| -x[1]}.to_h.keys.each {|x| puts x}