n = int(eval(input()))

count = 0

for i in range(n):

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

    count += r-l+1

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

count = 0

for i in range(n):

    li,ri = list(map(int,input().split()))

    count += ri-li+1

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

n = int(eval(input()))
count = 0
for i in range(n):
    li, ri = list(map(int, input().split()))
    count += ri - li + 1
print(count)

-    l, r = list(map(int, input().split())) -    count += r - l + 1 +    li, ri = list(map(int, input().split())) +    count += ri - li + 1