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()))



cnt = 0

for i in range(N):

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

  cnt += r - l + 1

print(cnt)
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()))
cnt = 0
for i in range(N):
    l, r = list(map(int, input().split()))
    cnt += r - l + 1
print(cnt)

-ans = 0 +cnt = 0 -    ans += r - l + 1 -print(ans) +    cnt += r - l + 1 +print(cnt)