#include <bits/stdc++.h>
#pragma GCC optimize("O2,Ofast,inline,unroll-all-loops,-ffast-math")
#pragma GCC target("popcnt")
using namespace std;
struct point {
  int x, y;
} ps[1010];
struct Line {
  int x, l, r;
  Line(int _x = 0, int _l = 0, int _r = 0) { x = _x, l = _l, r = _r; }
};
int match[2][1010], n;
bool mark[2][1010], vis[1010];
vector<int> nxt[2][1010];
vector<Line> vx, vy;
set<int> set_x, set_y;
set<pair<int, int> > set_point;
template <class T>
void read(T &x) {
  char ch = x = 0;
  bool fl = false;
  while (!isdigit(ch)) fl |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x = fl ? -x : x;
}
bool hungary(int x) {
  for (auto &v : nxt[0][x]) {
    if (!vis[v]) {
      vis[v] = true;
      if (!match[1][v] || hungary(match[1][v]))
        return match[0][x] = v, match[1][v] = x, true;
    }
  }
  return false;
}
void dfs(int x, int type) {
  mark[type][x] = true;
  for (auto &v : nxt[type][x]) {
    if ((match[type][x] == v) ^ type && !mark[type ^ 1][v]) dfs(v, type ^ 1);
  }
}
inline bool intersact(Line A, Line B) {
  return A.x >= B.l && A.x <= B.r && B.x >= A.l && B.x <= A.r;
}
int main() {
  read(n);
  for (int i = 1; i <= n; i++) {
    read(ps[i].x), read(ps[i].y);
    set_x.insert(ps[i].x), set_y.insert(ps[i].y);
    set_point.insert({ps[i].x, ps[i].y});
  }
  auto cmp_x = [&](point A, point B) {
    return A.x == B.x ? A.y < B.y : A.x < B.x;
  };
  auto cmp_y = [&](point A, point B) {
    return A.y == B.y ? A.x < B.x : A.y < B.y;
  };
  sort(ps + 1, ps + 1 + n, cmp_x);
  for (int i = 1; i <= n; i++)
    if (ps[i].x == ps[i - 1].x)
      vx.push_back(Line(ps[i].x, ps[i - 1].y, ps[i].y));
  sort(ps + 1, ps + 1 + n, cmp_y);
  for (int i = 1; i <= n; i++)
    if (ps[i].y == ps[i - 1].y)
      vy.push_back(Line(ps[i].y, ps[i - 1].x, ps[i].x));
  int szx = vx.size(), szy = vy.size();
  for (int i = 0; i < szx; i++)
    for (int j = 0; j < szy; j++)
      if (intersact(vx[i], vy[j]))
        if (set_point.find({vx[i].x, vy[j].x}) == set_point.end())
          nxt[0][i + 1].push_back(j + 1), nxt[1][j + 1].push_back(i + 1);
  for (int i = 1; i <= szx; i++) memset(vis, 0, sizeof(vis)), hungary(i);
  for (int i = 1; i <= szy; i++)
    if (!match[1][i]) dfs(i, 1);
  int ans_x = set_x.size(), ans_y = set_y.size();
  for (int i = 1; i <= szy; i++) ans_y += !mark[1][i];
  printf("%d\n", ans_y);
  sort(ps + 1, ps + 1 + n, cmp_y);
  for (int i = 1, lst = 0, tmp = 0; i <= n + 1; i++) {
    if (ps[i].y == ps[i - 1].y) {
      if (!mark[1][++tmp])
        printf("%d %d %d %d\n", lst, ps[i].y, ps[i - 1].x, ps[i].y),
            lst = ps[i].x;
    } else {
      if (i > 1)
        printf("%d %d %d %d\n", lst, ps[i - 1].y, ps[i - 1].x, ps[i - 1].y);
      lst = ps[i].x;
    }
  }
  for (int i = 1; i <= szx; i++) ans_x += mark[0][i];
  printf("%d\n", ans_x);
  sort(ps + 1, ps + n + 1, cmp_x);
  for (int i = 1, lst = 0, tmp = 0; i <= n + 1; i++) {
    if (ps[i].x == ps[i - 1].x) {
      if (mark[0][++tmp])
        printf("%d %d %d %d\n", ps[i].x, lst, ps[i].x, ps[i - 1].y),
            lst = ps[i].y;
    } else {
      if (i > 1)
        printf("%d %d %d %d\n", ps[i - 1].x, lst, ps[i - 1].x, ps[i - 1].y);
      lst = ps[i].y;
    }
  }
  return 0;
}
