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