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())
count = 0
for _ in range(n):
  a, b = map(int, input().split())
  count += abs(a-b)
print(count)
counter = 0
for i in range(int(input())):
  l, r = map(int, input().split())
  counter += r - l + 1
print(counter)