On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
N = int(input())
r = []
b = []
for i in range(N):
    r.append([int(i) for i in input().split()])

for i in range(N):
    b.append([int(i) for i in input().split()])

#print("r", r)
#print("b", b)

sorted_r = sorted(r)


sorted_b = sorted(b, key=lambda b:b[0], reverse=True)


ans = 0
for e1 in sorted_b:
    for e2 in sorted_r:
        if e1[0] < e2[0] and e1[1] > e2[1]:
            ans += 1
            sorted_r.remove(e2)
            break
print(ans)

N = int(input())
r = []
b = []
for i in range(N):
    r.append([int(i) for i in input().split()])

for i in range(N):
    b.append([int(i) for i in input().split()])

#print("r", r)
#print("b", b)

sorted_r = sorted(r, key=lambda r:r[1], reverse=True)
sorted_b = sorted(b)



ans = 0
for e1 in sorted_b:
    for e2 in sorted_r:
        if e2[0] < e1[0] and e2[1] < e1[1]:
            ans += 1
            sorted_r.remove(e2)
            break
print(ans)
