N = int(raw_input()) g = set([]) for i in range(N): x, y = map(int, raw_input().split()) if x >= y: print -1 break else: g.add(x - y) if len(g) > 1: print -1 print g.pop()