N = int(input()) s = set() for _ in range(N): x, y = map(int, input().split()) s.add(y - x) if len(s) > 1 or list(s)[0] <= 0: print(-1) else: print(list(s)[0])