puts$<.map{|s|s.split.map &:to_i}.zip(%w[A B C]).sort_by{|(h,w),|[-h,w]}.map &:pop