Joisino is working as a receptionist at a theater.  The theater has 100000 seats, numbered from 1 to 100000.  According to her memo, N groups of audiences have come so far, and the i-th group occupies the consecutive seats from Seat l_i to Seat r_i (inclusive).  How many people are sitting at the theater now?
n = int(input())
L = []
R = []
for _ in range(n):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

ans = 0
for i in range(n):
    ans += R[i] - L[i]

print(ans) 
n = int(input())
L = []
R = []
for _ in range(n):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

ans = 0
for i in range(n):
    ans += R[i] - L[i] + 1

print(ans) 