N = int(input()) A, B = 0, 0 for _ in range(N-1): a, b = map(int, input().split()) A += a B += b if A > B: print(A-B) elif A < B: print(B-A) else: print(A+1)