n = int(eval(input()))  

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

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

ans = 0

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

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



def count(red, blue):

    used_red = []

    used_blue = []

    for i in red:

        if i in used_red:

            continue

        for j in blue:

            if j in used_blue:

                continue

            if i[0] < j[0] and i[1] < j[1]:

                used_red.append(i)

                used_blue.append(j)

                break

    return len(used_red)



ans = count(red_li, blue_li)

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

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

ans = max(ans, count(red_li, blue_li))

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

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

ans = max(ans, count(red_li, blue_li))

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

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

ans = max(ans, count(red_li, blue_li))

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

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

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

ans = 0

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

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



def count(red, blue):

    used_red = []

    used_blue = []

    for i in red:

        if i in used_red:

            continue

        for j in blue:

            if j in used_blue:

                continue

            if i[0] < j[0] and i[1] < j[1]:

                used_red.append(i)

                used_blue.append(j)

                break

    return len(used_red)





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

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

ans = max(ans, count(red_li, blue_li))

print(ans)
n = int(eval(input()))
red_li = [list(map(int, input().split())) for _ in range(n)]
blue_li = [list(map(int, input().split())) for _ in range(n)]
ans = 0
red_li.sort(reverse=True, key=lambda x: (x[0], x[1]))
blue_li.sort(key=lambda x: (x[0], x[1]))


def count(red, blue):
    used_red = []
    used_blue = []
    for i in red:
        if i in used_red:
            continue
        for j in blue:
            if j in used_blue:
                continue
            if i[0] < j[0] and i[1] < j[1]:
                used_red.append(i)
                used_blue.append(j)
                break
    return len(used_red)


ans = count(red_li, blue_li)
red_li.sort(reverse=True, key=lambda x: (x[1], x[0]))
blue_li.sort(key=lambda x: (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
red_li.sort(reverse=True, key=lambda x: (x[1], x[0]))
blue_li.sort(key=lambda x: (x[0], x[1]))
ans = max(ans, count(red_li, blue_li))
red_li.sort(reverse=True, key=lambda x: (x[0], x[1]))
blue_li.sort(key=lambda x: (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
print(ans)

n = int(eval(input()))
red_li = [list(map(int, input().split())) for _ in range(n)]
blue_li = [list(map(int, input().split())) for _ in range(n)]
ans = 0
red_li.sort(reverse=True, key=lambda x: (x[0], x[1]))
blue_li.sort(key=lambda x: (x[0], x[1]))


def count(red, blue):
    used_red = []
    used_blue = []
    for i in red:
        if i in used_red:
            continue
        for j in blue:
            if j in used_blue:
                continue
            if i[0] < j[0] and i[1] < j[1]:
                used_red.append(i)
                used_blue.append(j)
                break
    return len(used_red)


red_li.sort(reverse=True, key=lambda x: (x[0], x[1]))
blue_li.sort(key=lambda x: (x[1], x[0]))
ans = max(ans, count(red_li, blue_li))
print(ans)

-ans = count(red_li, blue_li) -red_li.sort(reverse=True, key=lambda x: (x[1], x[0])) -blue_li.sort(key=lambda x: (x[1], x[0])) -ans = max(ans, count(red_li, blue_li)) -red_li.sort(reverse=True, key=lambda x: (x[1], x[0])) -blue_li.sort(key=lambda x: (x[0], x[1])) -ans = max(ans, count(red_li, blue_li))