# -*- coding: utf-8 -*-

n=int(eval(input()))

m=int(eval(input()))

ans=c=m

for i in range(n):

    a,b=[int(a) for a in input().split()]

    if c<0:

        continue

    c+=a-b

    if ans<c:

        ans=c

    if c<0:

        ans=0

print(ans)
n=int(eval(input()))

ans=c=m=int(eval(input()))

for i in[0]*n:

    a,b=list(map(int,input().split()))

    if c<0:ans=0;break

    c+=a-b

    ans=max(ans,c)

print(ans)
# -*- coding: utf-8 -*-
n = int(eval(input()))
m = int(eval(input()))
ans = c = m
for i in range(n):
    a, b = [int(a) for a in input().split()]
    if c < 0:
        continue
    c += a - b
    if ans < c:
        ans = c
    if c < 0:
        ans = 0
print(ans)

n = int(eval(input()))
ans = c = m = int(eval(input()))
for i in [0] * n:
    a, b = list(map(int, input().split()))
    if c < 0:
        ans = 0
        break
    c += a - b
    ans = max(ans, c)
print(ans)

-# -*- coding: utf-8 -*- -m = int(eval(input())) -ans = c = m -for i in range(n): -    a, b = [int(a) for a in input().split()] -    if c < 0: -        continue -    c += a - b -    if ans < c: -        ans = c +ans = c = m = int(eval(input())) +for i in [0] * n: +    a, b = list(map(int, input().split())) +        break +    c += a - b +    ans = max(ans, c)