n=int(eval(input()))

c=0

for i in range(n):

    l,r=input().split()

    c+=(int(r)-int(l)+1)



print(c)

c=0

n=int(eval(input()))

for i in range(n):

    l,r=list(map(int,input().split()))

    c+=(r-l+1)

print(c)

n = int(eval(input()))
c = 0
for i in range(n):
    l, r = input().split()
    c += int(r) - int(l) + 1
print(c)

c = 0
n = int(eval(input()))
for i in range(n):
    l, r = list(map(int, input().split()))
    c += r - l + 1
print(c)

+c = 0 -c = 0 -    l, r = input().split() -    c += int(r) - int(l) + 1 +    l, r = list(map(int, input().split())) +    c += r - l + 1