package main import "fmt" func main() { var N, v int fmt.Scan(&N) for i := 0; i < N; i++ { var x, y int fmt.Scan(&x, &y) if v == 0 { if y-x > 0 { v = y - x } else { v = -1 } } else if v != y-x { v = -1 } } fmt.Println(v) }