import std.stdio;
import std.range;
import std.array;
import std.string;
import std.conv;
import std.typecons;
import std.algorithm;
import std.container;
import std.typecons;
import std.random;
import std.csv;
import std.regex;
import std.math;
import core.time;
import std.ascii;
import std.digest.sha;

alias P = Tuple!(int, "x", int, "y");

bool comp(P a, P b)
{
	if (a.x >= b.x) {
		return false;
	}
	if (a.y >= b.y) {
		return false;
	}
	return true;
}

void main()
{
	int n = readln.chomp.to!int;
	P[] reds;
	foreach (i; 0..n) {
		auto ab = readln.chomp.split.map!(to!int);
		reds ~= P(ab.front, ab.back);
	}
	P[] blues;
	foreach (i; 0..n) {
		auto ab = readln.chomp.split.map!(to!int);
		blues ~= P(ab.front, ab.back);
	}
	int ans = 0;
	bool[ulong] doneR;
	bool[ulong] doneB;
	for (;;) {
		ulong[2][] ok;
		foreach (i, r; reds) {
			if (i in doneR) {
				continue;
			}
			foreach (j, b; blues) {
				if (j in doneB) {
					continue;
				}
				if (r.x < b.x) {
					ok ~= [i, j];
				}
			}
		}
		if (ok.length == 0) {
			break;
		}
		int[2] sub;
		int yabai = int.max;
		foreach (pair; ok) {
			auto r = reds[pair[0]];
			auto b = blues[pair[1]];
			if (r.y >= b.y) {
				continue;
			}
			int d = b.y - r.y;
			if (d < yabai) {
				yabai = d;
				sub = pair.to!(int[2]);
			}
		}
		if (yabai == int.max) {
			continue;
		}
		stderr.writeln(reds[sub[0]], " ", blues[sub[1]]);
		++ans;
		doneR[sub[0]] = true;
		doneB[sub[1]] = true;
	}
	ans.writeln;
}
