

N = int(eval(input()))

X = []

Y = []



for i in range(N):

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

  X.append((a, b))



for i in range(N):

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

  Y.append((c, d))





X.sort(key=lambda x: -x[1])

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



B = []

result = 0



for x in range(N):

  red = list(map(int, X[x]))



  for y in range(N):

    blue = list(map(int, Y[y]))

    if y in B:

      continue

    if red[0] < blue[0] and red[1] < blue[1]:

      result += 1

      B.append(y)

      break

  

print(result)






N = int(eval(input()))

RED = []

BLUE = []



for i in range(N):

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

  RED.append((a, b))



for i in range(N):

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

  BLUE.append((a, b))



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

RED.sort(key=lambda x: -x[1])





red_selected = set()

blue_selected = set()

for i in range(N):

  c, d = BLUE[i]

  

  for j in range(N):

    a, b = RED[j]

    if a < c and b < d and j not in red_selected and i not in blue_selected:

      red_selected.add(j)

      blue_selected.add(i)



print((len(red_selected)))
N = int(eval(input()))
X = []
Y = []
for i in range(N):
    a, b = list(map(int, input().split()))
    X.append((a, b))
for i in range(N):
    c, d = list(map(int, input().split()))
    Y.append((c, d))
X.sort(key=lambda x: -x[1])
Y.sort(key=lambda x: x[0])
B = []
result = 0
for x in range(N):
    red = list(map(int, X[x]))
    for y in range(N):
        blue = list(map(int, Y[y]))
        if y in B:
            continue
        if red[0] < blue[0] and red[1] < blue[1]:
            result += 1
            B.append(y)
            break
print(result)

N = int(eval(input()))
RED = []
BLUE = []
for i in range(N):
    a, b = list(map(int, input().split()))
    RED.append((a, b))
for i in range(N):
    a, b = list(map(int, input().split()))
    BLUE.append((a, b))
BLUE.sort(key=lambda x: x[0])
RED.sort(key=lambda x: -x[1])
red_selected = set()
blue_selected = set()
for i in range(N):
    c, d = BLUE[i]
    for j in range(N):
        a, b = RED[j]
        if a < c and b < d and j not in red_selected and i not in blue_selected:
            red_selected.add(j)
            blue_selected.add(i)
print((len(red_selected)))

-X = [] -Y = [] +RED = [] +BLUE = [] -    X.append((a, b)) +    RED.append((a, b)) -    c, d = list(map(int, input().split())) -    Y.append((c, d)) -X.sort(key=lambda x: -x[1]) -Y.sort(key=lambda x: x[0]) -B = [] -result = 0 -for x in range(N): -    red = list(map(int, X[x])) -    for y in range(N): -        blue = list(map(int, Y[y])) -        if y in B: -            continue -        if red[0] < blue[0] and red[1] < blue[1]: -            result += 1 -            B.append(y) -            break -print(result) +    a, b = list(map(int, input().split())) +    BLUE.append((a, b)) +BLUE.sort(key=lambda x: x[0]) +RED.sort(key=lambda x: -x[1]) +red_selected = set() +blue_selected = set() +for i in range(N): +    c, d = BLUE[i] +    for j in range(N): +        a, b = RED[j] +        if a < c and b < d and j not in red_selected and i not in blue_selected: +            red_selected.add(j) +            blue_selected.add(i) +print((len(red_selected)))