n = int(eval(input()))

A = [[int(i) for i in input().split()] for j in range(n)]

C = [[int(i) for i in input().split()] for j in range(n)]





ans = []



for bits in range(1, 2**4):

    cnt = 0

    used = [False] * n

    A.sort(key=lambda x:x[bits & 1], reverse=bits >> 1 & 1)

    C.sort(key=lambda x:x[bits >> 2 & 1], reverse=bits >> 3 & 1)



    for a, b in A:

        i = 0

        while i < n and (used[i] or a >= C[i][0] or b >= C[i][1]):

            i += 1

        if i >= n:

            continue

        cnt += 1

        used[i] = True

        i += 1

        



    ans.append(cnt)



print((max(ans)))

n = int(eval(input()))

A = [[int(i) for i in input().split()] for j in range(n)]

C = [[int(i) for i in input().split()] for j in range(n)]





ans = 0

used = [False] * n

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

C.sort()



for c, d in C:

    i = 0

    while i < n and (used[i] or A[i][0] >= c or A[i][1] >= d):

        i += 1

    if i >= n:

        continue

    ans += 1

    used[i] = True



print(ans)
n = int(eval(input()))
A = [[int(i) for i in input().split()] for j in range(n)]
C = [[int(i) for i in input().split()] for j in range(n)]
ans = []
for bits in range(1, 2**4):
    cnt = 0
    used = [False] * n
    A.sort(key=lambda x: x[bits & 1], reverse=bits >> 1 & 1)
    C.sort(key=lambda x: x[bits >> 2 & 1], reverse=bits >> 3 & 1)
    for a, b in A:
        i = 0
        while i < n and (used[i] or a >= C[i][0] or b >= C[i][1]):
            i += 1
        if i >= n:
            continue
        cnt += 1
        used[i] = True
        i += 1
    ans.append(cnt)
print((max(ans)))

n = int(eval(input()))
A = [[int(i) for i in input().split()] for j in range(n)]
C = [[int(i) for i in input().split()] for j in range(n)]
ans = 0
used = [False] * n
A.sort(key=lambda x: x[1], reverse=True)
C.sort()
for c, d in C:
    i = 0
    while i < n and (used[i] or A[i][0] >= c or A[i][1] >= d):
        i += 1
    if i >= n:
        continue
    ans += 1
    used[i] = True
print(ans)

-ans = [] -for bits in range(1, 2**4): -    cnt = 0 -    used = [False] * n -    A.sort(key=lambda x: x[bits & 1], reverse=bits >> 1 & 1) -    C.sort(key=lambda x: x[bits >> 2 & 1], reverse=bits >> 3 & 1) -    for a, b in A: -        i = 0 -        while i < n and (used[i] or a >= C[i][0] or b >= C[i][1]): -            i += 1 -        if i >= n: -            continue -        cnt += 1 -        used[i] = True +ans = 0 +used = [False] * n +A.sort(key=lambda x: x[1], reverse=True) +C.sort() +for c, d in C: +    i = 0 +    while i < n and (used[i] or A[i][0] >= c or A[i][1] >= d): -    ans.append(cnt) -print((max(ans))) +    if i >= n: +        continue +    ans += 1 +    used[i] = True +print(ans)