import collections

n = int(eval(input()))

l = [list(map(int, input().split())) for _ in range(n)]

d = {}

for i in range(len(l)):

    for j in range(l[i][0], l[i][1] + 1):

        d[j] = 1

print((len(d)))

n = int(eval(input()))

t = 0

for i in range(n):

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

    t += (r - l + 1)

print(t)

import collections

n = int(eval(input()))
l = [list(map(int, input().split())) for _ in range(n)]
d = {}
for i in range(len(l)):
    for j in range(l[i][0], l[i][1] + 1):
        d[j] = 1
print((len(d)))

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

-import collections - -l = [list(map(int, input().split())) for _ in range(n)] -d = {} -for i in range(len(l)): -    for j in range(l[i][0], l[i][1] + 1): -        d[j] = 1 -print((len(d))) +t = 0 +for i in range(n): +    l, r = list(map(int, input().split())) +    t += r - l + 1 +print(t)