# 数値は別の提出がチェックしていたはず firstline = gets.chomp! abort "line1 format error" unless /^\d+ \d+$/=~firstline n,m = firstline.split.map(&:to_i) m.times{|i| line = gets abort "idx#{i} return error" unless line.chomp! abort "idx#{i} format error" unless /^\d+ \d+$/=~line } abort "end of line error" if gets puts "Impossible"