import sys

input = sys.stdin.readline

N = int(eval(input()))

R = []

B = []

ans = 0

for i in range(N):

  a,b = list(map(int,input().split()))

  R.append((a,b))

for i in range(N):

  c,d = list(map(int,input().split()))

  B.append((c,d))

R.sort(key=lambda x:x[0])

B.sort(key=lambda x:x[0])

H = []

l = 0

for i in range(N):

  for j in range(l,N):

    if R[j][0] > B[i][0]:

      l = j

      break

    H.append(R[j])

  H.sort(key=lambda x:x[1], reverse=True)

  for k in range(len(H)):

    if H[k][1] < B[i][1]:

      H.pop(k)

      ans += 1

      break

print(ans)
N = int(eval(input()))

red = []

blue = []

chosen = [0]*N

ans = 0

for i in range(N):

  a,b = list(map(int, input().split()))

  red.append((a,b))

for i in range(N):

  c,d = list(map(int, input().split()))

  blue.append((c,d))

  

red.sort(key=lambda x:x[1],reverse=True)

blue.sort(key=lambda x:x[0])



for i in range(N):

  for j in range(N):

    if blue[i][0] >= red[j][0] and blue[i][1] >= red[j][1] and chosen[j] == 0:

      chosen[j] = 1

      ans += 1

      break

      

print(ans)
import sys

input = sys.stdin.readline
N = int(eval(input()))
R = []
B = []
ans = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    R.append((a, b))
for i in range(N):
    c, d = list(map(int, input().split()))
    B.append((c, d))
R.sort(key=lambda x: x[0])
B.sort(key=lambda x: x[0])
H = []
l = 0
for i in range(N):
    for j in range(l, N):
        if R[j][0] > B[i][0]:
            l = j
            break
        H.append(R[j])
    H.sort(key=lambda x: x[1], reverse=True)
    for k in range(len(H)):
        if H[k][1] < B[i][1]:
            H.pop(k)
            ans += 1
            break
print(ans)

N = int(eval(input()))
red = []
blue = []
chosen = [0] * N
ans = 0
for i in range(N):
    a, b = list(map(int, input().split()))
    red.append((a, b))
for i in range(N):
    c, d = list(map(int, input().split()))
    blue.append((c, d))
red.sort(key=lambda x: x[1], reverse=True)
blue.sort(key=lambda x: x[0])
for i in range(N):
    for j in range(N):
        if blue[i][0] >= red[j][0] and blue[i][1] >= red[j][1] and chosen[j] == 0:
            chosen[j] = 1
            ans += 1
            break
print(ans)

-import sys - -input = sys.stdin.readline -R = [] -B = [] +red = [] +blue = [] +chosen = [0] * N -    R.append((a, b)) +    red.append((a, b)) -    B.append((c, d)) -R.sort(key=lambda x: x[0]) -B.sort(key=lambda x: x[0]) -H = [] -l = 0 +    blue.append((c, d)) +red.sort(key=lambda x: x[1], reverse=True) +blue.sort(key=lambda x: x[0]) -    for j in range(l, N): -        if R[j][0] > B[i][0]: -            l = j -            break -        H.append(R[j]) -    H.sort(key=lambda x: x[1], reverse=True) -    for k in range(len(H)): -        if H[k][1] < B[i][1]: -            H.pop(k) +    for j in range(N): +        if blue[i][0] >= red[j][0] and blue[i][1] >= red[j][1] and chosen[j] == 0: +            chosen[j] = 1