"use strict";

function main(input) {
  var inputs = input.split("\n");

  var N = parseInt(inputs[0], 10)
  var a = inputs.slice(1, N + 1).map((v, i) =>
    v.split(" ").map((v, i) => parseInt(v, 10))
  );
  var c = inputs.slice(N + 1, 2 * N + 1).map((v, i) =>
    v.split(" ").map((v, i) => parseInt(v, 10))
  );
  a.sort((a, b) => b[1] - a[1]);
  c.sort((a, b) => a[0] - b[0]);

  console.log("a");
  console.log(a.reduce((acc, v) => acc + "\n" + v));
  console.log("c");
  console.log(c.reduce((acc, v) => acc + "\n" + v));


  var result = 0;

  for (let ci = 0; ci < c.length; ci++) {
    for (let ai = 0; ai < a.length; ai++) {
      if (a[ai][0] < c[ci][0] && a[ai][1] < c[ci][1]) {
        a[ai][0] = a[ai][1] = 100 * N;
        result++;
        break;
      }
    }
  }

  console.log(result);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));
