class Calc0201 def initialize(args) args = args.map { |l| l.chomp.split(/\s+/) } @sa, @pa, @xa = args.shift @sb, @pb, @xb = args.shift end def calc k = [@pa.size, @pb.size].max @pa.rjust(k, '0') <=> @pb.rjust(k, '0') end def run case calc when 0 -1 when 1 @sa when -1 @sb end end end puts Calc0201.new(STDIN.readlines).run if __FILE__ == $0