from operator import itemgetter

N = int(eval(input()))

A = [tuple(map(int,input().split())) for i in range(N)]

B = [tuple(map(int,input().split())) for i in range(N)]

A.sort()

B.sort()

num = 0

for i in range(N):

    K = [A[k] for k in range(len(A)) if (A[k][0] <B[i][0]) and (A[k][1] < B[i][1])]

    if K:

        num += 1

        t = sorted(K, key=itemgetter(1))[-1]

        A.remove(t)

print(num)
from operator import itemgetter

n=int(eval(input()))

A=[tuple(map(int,input().split())) for i in range(n)]

B=[tuple(map(int,input().split())) for j in range(n)]

A.sort()

B.sort()

count=0

for i in range(n):

    box=[A[j] for j in range(len(A)) if (A[j][0]<B[i][0]) and (A[j][1]<B[i][1])]

    if any(box):

        box=sorted(box, key=itemgetter(1))

        A.remove(box[-1])

        count +=1

print(count)
from operator import itemgetter

N = int(eval(input()))
A = [tuple(map(int, input().split())) for i in range(N)]
B = [tuple(map(int, input().split())) for i in range(N)]
A.sort()
B.sort()
num = 0
for i in range(N):
    K = [A[k] for k in range(len(A)) if (A[k][0] < B[i][0]) and (A[k][1] < B[i][1])]
    if K:
        num += 1
        t = sorted(K, key=itemgetter(1))[-1]
        A.remove(t)
print(num)

from operator import itemgetter

n = int(eval(input()))
A = [tuple(map(int, input().split())) for i in range(n)]
B = [tuple(map(int, input().split())) for j in range(n)]
A.sort()
B.sort()
count = 0
for i in range(n):
    box = [A[j] for j in range(len(A)) if (A[j][0] < B[i][0]) and (A[j][1] < B[i][1])]
    if any(box):
        box = sorted(box, key=itemgetter(1))
        A.remove(box[-1])
        count += 1
print(count)

-N = int(eval(input())) -A = [tuple(map(int, input().split())) for i in range(N)] -B = [tuple(map(int, input().split())) for i in range(N)] +n = int(eval(input())) +A = [tuple(map(int, input().split())) for i in range(n)] +B = [tuple(map(int, input().split())) for j in range(n)] -num = 0 -for i in range(N): -    K = [A[k] for k in range(len(A)) if (A[k][0] < B[i][0]) and (A[k][1] < B[i][1])] -    if K: -        num += 1 -        t = sorted(K, key=itemgetter(1))[-1] -        A.remove(t) -print(num) +count = 0 +for i in range(n): +    box = [A[j] for j in range(len(A)) if (A[j][0] < B[i][0]) and (A[j][1] < B[i][1])] +    if any(box): +        box = sorted(box, key=itemgetter(1)) +        A.remove(box[-1]) +        count += 1 +print(count)