N = int(eval(input()))

R = [(-1, -1)] * N

for n in range(N):

    x, y = list(map(int, input().split()))

    R[n] = (x, y)

B = [(-1, -1)] * N

for n in range(N):

    x, y = list(map(int, input().split()))

    B[n] = (x, y)



B = sorted(B)

R = sorted(R, reverse=True)



ans = 0

for i, b in enumerate(B):

    tmp = []

    for j, r in enumerate(R):

        if r[0] == -1:

            continue

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

            tmp.append((j, r))

    if tmp:

        tmp = sorted(tmp, key=lambda x: x[1][1], reverse=True)

        R[tmp[0][0]] = (-1, -1)

        ans += 1



print(ans)
N = int(eval(input()))

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

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

R = sorted(R)

B = sorted(B)



res = 0

for bx, by in B:

    idx = -1

    tmp = -1

    for i, (rx, ry) in enumerate(R):

        if rx < bx and ry < by:

            if ry >= tmp:

                tmp = ry

                idx = i

    if idx != -1:

        R.pop(idx)

        res += 1

print(res)
N = int(eval(input()))
R = [(-1, -1)] * N
for n in range(N):
    x, y = list(map(int, input().split()))
    R[n] = (x, y)
B = [(-1, -1)] * N
for n in range(N):
    x, y = list(map(int, input().split()))
    B[n] = (x, y)
B = sorted(B)
R = sorted(R, reverse=True)
ans = 0
for i, b in enumerate(B):
    tmp = []
    for j, r in enumerate(R):
        if r[0] == -1:
            continue
        if r[0] < b[0] and r[1] < b[1]:
            tmp.append((j, r))
    if tmp:
        tmp = sorted(tmp, key=lambda x: x[1][1], reverse=True)
        R[tmp[0][0]] = (-1, -1)
        ans += 1
print(ans)

N = int(eval(input()))
R = [tuple(map(int, input().split())) for _ in range(N)]
B = [tuple(map(int, input().split())) for _ in range(N)]
R = sorted(R)
B = sorted(B)
res = 0
for bx, by in B:
    idx = -1
    tmp = -1
    for i, (rx, ry) in enumerate(R):
        if rx < bx and ry < by:
            if ry >= tmp:
                tmp = ry
                idx = i
    if idx != -1:
        R.pop(idx)
        res += 1
print(res)

-R = [(-1, -1)] * N -for n in range(N): -    x, y = list(map(int, input().split())) -    R[n] = (x, y) -B = [(-1, -1)] * N -for n in range(N): -    x, y = list(map(int, input().split())) -    B[n] = (x, y) +R = [tuple(map(int, input().split())) for _ in range(N)] +B = [tuple(map(int, input().split())) for _ in range(N)] +R = sorted(R) -R = sorted(R, reverse=True) -ans = 0 -for i, b in enumerate(B): -    tmp = [] -    for j, r in enumerate(R): -        if r[0] == -1: -            continue -        if r[0] < b[0] and r[1] < b[1]: -            tmp.append((j, r)) -    if tmp: -        tmp = sorted(tmp, key=lambda x: x[1][1], reverse=True) -        R[tmp[0][0]] = (-1, -1) -        ans += 1 -print(ans) +res = 0 +for bx, by in B: +    idx = -1 +    tmp = -1 +    for i, (rx, ry) in enumerate(R): +        if rx < bx and ry < by: +            if ry >= tmp: +                tmp = ry +                idx = i +    if idx != -1: +        R.pop(idx) +        res += 1 +print(res)