n= int(input()) for i in range(n): a,b = map(int,input().split()) if b-a<=0: print(-1) exit() if i > 0: if test!= b - a: print(-1) exit() test = b - a print(b-a)