S = set() for _ in range(int(input())): X,Y = map(int,input().split()) S.add(Y-X) x = S.pop() if S or x <= 0: print(-1) else: print(x)