N = int(eval(input()))

ans = 0

for i in range(N):

    lr = list(map(int, input().split()))

    ans += lr[1] - lr[0] +1

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

ans = 0

for i in range(N):

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

    ans += r-l+1

print(ans)
N = int(eval(input()))
ans = 0
for i in range(N):
    lr = list(map(int, input().split()))
    ans += lr[1] - lr[0] + 1
print(ans)

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

-    lr = list(map(int, input().split())) -    ans += lr[1] - lr[0] + 1 +    l, r = list(map(int, input().split())) +    ans += r - l + 1