a = nil gets.to_i.times do x, y = gets.split.map &:to_i z = y - x if(z > 0) if a a = a == z ? a : -1 else a = z end else a = -1 end end puts a