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