#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int rx[110], ry[110], bx[110], by[110];
  for (int i = 0; i < N; i++) cin >> rx[i] >> ry[i];
  for (int i = 0; i < N; i++) cin >> bx[i] >> by[i];
  int r[110] = {0};
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if ((rx[i] < bx[j]) && (ry[i] < by[j])) r[i]++;
    }
  }
  int bs[110], rs[110];
  for (int i = 0; i < N; i++) {
    bs[i] = 0;
    rs[i] = 0;
  }
  int temp_x, temp_y;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N - 1; j++) {
      if (r[j + 1] < r[j]) temp_x = rx[i];
      temp_y = ry[i];
      rx[i] = rx[j];
      ry[i] = ry[j];
      rx[j] = temp_x;
      ry[j] = temp_y;
    }
  }
  for (int i = 0; i < N; i++) {
    cout << rx[i] << '\n';
  }
  int count = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if ((rx[i] < bx[j]) && (ry[i] < by[j]) && (bs[j] == 0) && (rs[i] == 0)) {
        bs[j] = 1;
        rs[i] = 1;
        count++;
      }
    }
  }
  cout << count << '\n';
  return 0;
}
