gets a = $stdin.read.lines.map{|s| x, y = s.split.map(&:to_i); y - x}.uniq puts a.size == 1 && a[0] > 0 ? a[0] : -1