test_case = gets.chomp.to_i list = Array.new for i in 0...test_case do x, y = gets.chomp.split.map(&:to_i) list << (y - x) end if list.uniq.length == 1 && list.uniq[0] > 0 puts list.uniq else puts -1 end