member = [] for _ in range(int(input())): a, b = map(int, input().split()) member.append([a, b]) item = [] for _ in range(int(input())): a, b = map(int, input().split()) item.append([a, b]) count = 0 for [a, b] in member: for [x, y] in item: if a <= x and b >= y: count += 1 print(count)