N=int(input()) A=set() for i in range(N): x,y=map(int,input().split()) A.add(y-x) if len(A)==1: x=A.pop() if x>0: print(x) else: print(-1) else: print(-1)