n = int(eval(input()))

red = [list(map(int,input().split())) for _ in range(n)]

blue = [list(map(int,input().split())) for _ in range(n)]

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

check = [False]*n

for i in range(n):

    a = -1

    c = -1

    for j in range(n):

        if check[j]:continue

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

            if a < red[j][1]:

                a = red[j][1]

                c = j

    if c != -1:

        check[c] = True

print((check.count(True)))
n = int(eval(input()))

red = [list(map(int,input().split())) for _ in range(n)]

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

blue = sorted(list(map(int,input().split())) for _ in range(n))

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

seen = [False]*n

for i in range(n):

    check = -1

    for j in range(n):

        if seen[j]:continue

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

            check = j

    if check != -1:seen[check] = True

print((seen.count(True)))
n = int(eval(input()))
red = [list(map(int, input().split())) for _ in range(n)]
blue = [list(map(int, input().split())) for _ in range(n)]
blue.sort(key=lambda x: (x[0], x[1]))
check = [False] * n
for i in range(n):
    a = -1
    c = -1
    for j in range(n):
        if check[j]:
            continue
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
            if a < red[j][1]:
                a = red[j][1]
                c = j
    if c != -1:
        check[c] = True
print((check.count(True)))

n = int(eval(input()))
red = [list(map(int, input().split())) for _ in range(n)]
red.sort(key=lambda x: (x[1]))
blue = sorted(list(map(int, input().split())) for _ in range(n))
blue.sort(key=lambda x: (x[0], x[1]))
seen = [False] * n
for i in range(n):
    check = -1
    for j in range(n):
        if seen[j]:
            continue
        if blue[i][0] > red[j][0] and blue[i][1] > red[j][1]:
            check = j
    if check != -1:
        seen[check] = True
print((seen.count(True)))

-blue = [list(map(int, input().split())) for _ in range(n)] +red.sort(key=lambda x: (x[1])) +blue = sorted(list(map(int, input().split())) for _ in range(n)) -check = [False] * n +seen = [False] * n -    a = -1 -    c = -1 +    check = -1 -        if check[j]: +        if seen[j]: -            if a < red[j][1]: -                a = red[j][1] -                c = j -    if c != -1: -        check[c] = True -print((check.count(True))) +            check = j +    if check != -1: +        seen[check] = True +print((seen.count(True)))