N=int(eval(input()))

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

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



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

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



ans=0

r_used=[False]*N

for b in BLUE:

    for j,r in enumerate(RED):

        if r_used[j]: continue

        if r[0]<b[0] and r[1]<b[1]:

            ans+=1

            r_used[j]=True

            break

print(ans)
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)

import sys

def main(N, AB, CD):

    ans = 0

    AB.sort(key=lambda x: x[0], reverse=True)

    for a, b in AB:

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

        idx = 0

        while idx < len(CD):

            c, d = CD[idx]

            if a < c and b < d:

                break

            idx += 1

        else:

            continue

        ans += 1

        del CD[idx]

    print(ans)





if __name__ == '__main__':

    input = sys.stdin.readline

    N = int(eval(input()))

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

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

    main(N, AB, CD)

N = int(eval(input()))
RED = [tuple(map(int, input().split())) for _ in range(N)]
BLUE = [tuple(map(int, input().split())) for _ in range(N)]
RED.sort(key=lambda x: x[1], reverse=True)
BLUE.sort(key=lambda x: x[0])
ans = 0
r_used = [False] * N
for b in BLUE:
    for j, r in enumerate(RED):
        if r_used[j]:
            continue
        if r[0] < b[0] and r[1] < b[1]:
            ans += 1
            r_used[j] = True
            break
print(ans)

# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys


def main(N, AB, CD):
    ans = 0
    AB.sort(key=lambda x: x[0], reverse=True)
    for a, b in AB:
        CD.sort(key=lambda x: x[1])
        idx = 0
        while idx < len(CD):
            c, d = CD[idx]
            if a < c and b < d:
                break
            idx += 1
        else:
            continue
        ans += 1
        del CD[idx]
    print(ans)


if __name__ == "__main__":
    input = sys.stdin.readline
    N = int(eval(input()))
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    CD = [tuple(map(int, input().split())) for _ in range(N)]
    main(N, AB, CD)

-N = int(eval(input())) -RED = [tuple(map(int, input().split())) for _ in range(N)] -BLUE = [tuple(map(int, input().split())) for _ in range(N)] -RED.sort(key=lambda x: x[1], reverse=True) -BLUE.sort(key=lambda x: x[0]) -ans = 0 -r_used = [False] * N -for b in BLUE: -    for j, r in enumerate(RED): -        if r_used[j]: +# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..) +import sys + + +def main(N, AB, CD): +    ans = 0 +    AB.sort(key=lambda x: x[0], reverse=True) +    for a, b in AB: +        CD.sort(key=lambda x: x[1]) +        idx = 0 +        while idx < len(CD): +            c, d = CD[idx] +            if a < c and b < d: +                break +            idx += 1 +        else: -        if r[0] < b[0] and r[1] < b[1]: -            ans += 1 -            r_used[j] = True -            break -print(ans) +        ans += 1 +        del CD[idx] +    print(ans) + + +if __name__ == "__main__": +    input = sys.stdin.readline +    N = int(eval(input())) +    AB = [tuple(map(int, input().split())) for _ in range(N)] +    CD = [tuple(map(int, input().split())) for _ in range(N)] +    main(N, AB, CD)