class Main Brother = Struct.new(:i, :h, :w) def start brothers = main brothers.sort_by! { |x| x.w } brothers.sort_by!.with_index { |x, i| x.h } brothers.reverse! echo brothers.map { |x| x.i }.join("\n") self.class.send(:remove_const, :Brother) return nil end private def main a = [] for i in 0...3 h, w = input.split brother = Brother.new(("A".ord + i).chr, h, w) a += [brother] end resturn a end def echo(*x) print(*x) puts end def input = gets.chomp end Main.new.start