train = [[0]*2 for i in range(10)]
num = 0
answer = []
for i in range(10):
train[i] = list(map(int, input().split()))
num = num - train[i][0] + train[i][1]
answer.append(num)
print(max(answer))
num = 0
answer = []
for i in range(10):
a, b = map(int, input().split())
num = num - a + b
answer.append(num)
print(max(answer))