n=int(eval(input()))

a=s=int(eval(input()))

b=1

for _ in[0]*n:

 i,o=list(map(int,input().split()))

 s+=i-o

 if s<0:b=0;break

 if a<s:a=s

print((a*b))

import sys

eval(input())

a=s=int(eval(input()))

b=1

for e in sys.stdin:

 i,o=list(map(int,e.split()))

 s+=i-o

 if s<0:b=0;break

 if a<s:a=s

print((a*b))

n = int(eval(input()))
a = s = int(eval(input()))
b = 1
for _ in [0] * n:
    i, o = list(map(int, input().split()))
    s += i - o
    if s < 0:
        b = 0
        break
    if a < s:
        a = s
print((a * b))

import sys

eval(input())
a = s = int(eval(input()))
b = 1
for e in sys.stdin:
    i, o = list(map(int, e.split()))
    s += i - o
    if s < 0:
        b = 0
        break
    if a < s:
        a = s
print((a * b))

-n = int(eval(input())) +import sys + +eval(input()) -for _ in [0] * n: -    i, o = list(map(int, input().split())) +for e in sys.stdin: +    i, o = list(map(int, e.split()))