n = int(eval(input()))

ab = []

cd = []

for _ in range(n):

    a, b = list(map(int, input().split()))

    ab.append([a, b])

for _ in range(n):

    c, d = list(map(int, input().split()))

    cd.append([c, d])

cd.sort()

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

tableA = [False for _ in range(n)]

tableB = [False for _ in range(n)]

ans = 0

for b in range(n):

    for r in range(n):

        if tableA[r] is True or tableB[b] is True:

            continue

        if cd[b][0]>ab[r][0] and cd[b][1]>ab[r][1]:

            tableA[r] = True

            tableB[b] = True

            ans += 1

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

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

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

R.sort()

B.sort()

pair = []



for bx, by in B:

    tmp = [r for r in R if r[0] < bx]

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

    for rx, ry in tmp[::-1]:

        if ry < by:

            pair.append([[rx, ry], [bx, by]])

            R.pop(R.index([rx, ry]))

            break



print((len(pair)))
n = int(eval(input()))
ab = []
cd = []
for _ in range(n):
    a, b = list(map(int, input().split()))
    ab.append([a, b])
for _ in range(n):
    c, d = list(map(int, input().split()))
    cd.append([c, d])
cd.sort()
ab.sort(reverse=True, key=lambda x: x[1])
tableA = [False for _ in range(n)]
tableB = [False for _ in range(n)]
ans = 0
for b in range(n):
    for r in range(n):
        if tableA[r] is True or tableB[b] is True:
            continue
        if cd[b][0] > ab[r][0] and cd[b][1] > ab[r][1]:
            tableA[r] = True
            tableB[b] = True
            ans += 1
print(ans)

n = int(eval(input()))
R = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(n)]
R.sort()
B.sort()
pair = []
for bx, by in B:
    tmp = [r for r in R if r[0] < bx]
    tmp.sort(key=lambda x: x[1])
    for rx, ry in tmp[::-1]:
        if ry < by:
            pair.append([[rx, ry], [bx, by]])
            R.pop(R.index([rx, ry]))
            break
print((len(pair)))

-ab = [] -cd = [] -for _ in range(n): -    a, b = list(map(int, input().split())) -    ab.append([a, b]) -for _ in range(n): -    c, d = list(map(int, input().split())) -    cd.append([c, d]) -cd.sort() -ab.sort(reverse=True, key=lambda x: x[1]) -tableA = [False for _ in range(n)] -tableB = [False for _ in range(n)] -ans = 0 -for b in range(n): -    for r in range(n): -        if tableA[r] is True or tableB[b] is True: -            continue -        if cd[b][0] > ab[r][0] and cd[b][1] > ab[r][1]: -            tableA[r] = True -            tableB[b] = True -            ans += 1 -print(ans) +R = [list(map(int, input().split())) for _ in range(n)] +B = [list(map(int, input().split())) for _ in range(n)] +R.sort() +B.sort() +pair = [] +for bx, by in B: +    tmp = [r for r in R if r[0] < bx] +    tmp.sort(key=lambda x: x[1]) +    for rx, ry in tmp[::-1]: +        if ry < by: +            pair.append([[rx, ry], [bx, by]]) +            R.pop(R.index([rx, ry])) +            break +print((len(pair)))