On a two-dimensional plane, there are N red points and N blue points. The coordinates of the i-th red point are (a_i, b_i), and the coordinates of the i-th blue point are (c_i, d_i).  A red point and a blue point can form a _friendly pair_ when, the x-coordinate of the red point is smaller than that of the blue point, and the y-coordinate of the red point is also smaller than that of the blue point.  At most how many friendly pairs can you form? Note that a point cannot belong to multiple pairs.
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
c = [list(map(int, input().split())) for _ in range(N)]
a.sort(key=lambda x: (x[0], x[1]))
c.sort(key=lambda x: (x[0], x[1]))
cnt = 0

print(cnt)
import copy

N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
b = [list(map(int, input().split())) for _ in range(N)]

chk = [0] * (2 * N)
cpchk =[]
pare = [-1] * (2 * N)
ans = 0

d = [[] for _ in range(2 * N)]
for i in range(N):
    for j in range(N):
        if a[i][0] < b[j][0] and a[i][1] < b[j][1]:
            d[i].append(j + N), d[j + N].append(i)

def dfs(v):
    cpchk[v] = 1
    for i in range(len(d[v])):
        u = d[v][i]
        w = pare[u]
        if w < 0 or cpchk[w] == 0 and dfs(w):
            pare[v] = u
            pare[u] = v
            return True
    return False

def bipartite_mattinc():
    global ans
    global cpchk
    for i in range(2 * N):
        if pare[i] < 0:
            cpchk = copy.deepcopy(chk)
            if dfs(i):
                ans += 1
    return ans

print(bipartite_mattinc())