#include <bits/stdc++.h>
std::vector<int> node[1024 * 2];
int ma[1024 * 2], ch[1024 * 2], tm;
int l[1024 * 2], f[1024 * 2];
std::pair<int, int> poi[1024];
std::map<int, int> prer, prec;
int *lr = l, *lc = l + 1024;
int *fr = f, *fc = f + 1024;
int dfs(int u) {
  f[u] = 1;
  for (auto v : node[u]) {
    if (ch[v] == tm) continue;
    ch[v] = tm;
    f[v] = 0;
    if (ma[v] == -1 || dfs(ma[v])) return ma[v] = u, ma[u] = v, 1;
  }
  return 0;
}
int main() {
  int n, cr = 0, cc = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) scanf("%d%d", &poi[i].first, &poi[i].second);
  std::sort(poi + 1, poi + 1 + n);
  for (int i = 1; i <= n; ++i) {
    int r = poi[i].first, c = poi[i].second;
    lr[i] = prer[r], prer[r] = i;
    lc[i] = prec[c], prec[c] = i;
  }
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j)
      if (lr[i] && poi[i].second > poi[j].second &&
          poi[lr[i]].second < poi[j].second && lc[j] &&
          poi[j].first > poi[i].first && poi[lc[j]].first < poi[i].first) {
        node[i].push_back(j + 1024), node[j + 1024].push_back(i);
        0;
      }
  memset(ma, -1, sizeof(ma));
  for (int i = 0; i < 1024 * 2; ++i)
    if (l[i] && ma[i] == -1) ++tm, dfs(i);
  for (int i = 1; i <= n; ++i) cc += !fc[i];
  printf("%d\n", cc);
  ++tm;
  for (int i = n; i; --i)
    if (ch[i] != tm) {
      ch[i] = tm;
      int j = i;
      while (fc[j]) j = lc[j], ch[j] = tm;
      printf("%d %d %d %d\n", poi[i].first, poi[i].second, poi[j].first,
             poi[j].second);
    }
  for (int i = 1; i <= n; ++i) cr += !fr[i];
  printf("%d\n", cr);
  ++tm;
  for (int i = n; i; --i)
    if (ch[i] != tm) {
      ch[i] = tm;
      int j = i;
      while (fr[j]) j = lr[j], ch[j] = tm;
      printf("%d %d %d %d\n", poi[i].first, poi[i].second, poi[j].first,
             poi[j].second);
    }
  return 0;
}
