#include <bits/stdc++.h>
using namespace std;
struct dot {
  long long x, y, pos;
} a[2005], b[2005];
struct edge {
  long long to, nxt, val;
} e[2000005 << 1];
queue<long long> q;
long long j, aaa, las, pp[2005], val, vv[2005], vst[2005], node[2005],
    nxt[2005], cur[2005], dis[2005], s, t, tot = 1;
inline void add(long long x, long long y, long long v) {
  e[++tot].nxt = node[x];
  e[tot].to = y;
  e[tot].val = v;
  node[x] = tot;
}
inline void ADD(long long x, long long y) {
  add(x, y, 1);
  add(y, x, 0);
}
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long bfs() {
  q.push(s);
  memset(dis, -1, sizeof(dis));
  dis[s] = 0;
  long long now, i, to;
  while (q.size()) {
    now = q.front();
    q.pop();
    for (i = node[now]; i; i = e[i].nxt) {
      to = e[i].to;
      if ((!e[i].val) || (~dis[to])) {
        continue;
      }
      dis[to] = dis[now] + 1;
      q.push(to);
    }
  }
  return ~dis[t];
}
long long dfs(long long now, long long flow) {
  if (now == t) return flow;
  long long qwq, flown = 0, &i = cur[now], to;
  for (; i; i = e[i].nxt) {
    to = e[i].to;
    if (dis[to] == dis[now] + 1 && e[i].val) {
      qwq = dfs(to, min(e[i].val, flow));
      flow -= qwq;
      flown += qwq;
      e[i].val -= qwq;
      e[i ^ 1].val += qwq;
      if (!flow) return flown;
    }
  }
  return flown;
}
inline long long dinic() {
  long long ret = 0;
  while (bfs()) {
    memcpy(cur, node, sizeof(node));
    ret += dfs(s, 1e9);
  }
  return ret;
}
long long n, m, i, x, y, v;
inline bool cmp(dot aa, dot bb) {
  if (aa.x == bb.x) return aa.y < bb.y;
  return aa.x < bb.x;
}
inline bool CMP(dot aa, dot bb) {
  if (aa.y == bb.y) return aa.x < bb.x;
  return aa.y < bb.y;
}
void Dfs(long long now) {
  vst[now] = 1;
  if (now > n) {
    for (long long i = node[now]; i; i = e[i].nxt) {
      if (e[i].to <= n && pp[e[i].to] != now && !vst[e[i].to]) Dfs(e[i].to);
    }
  } else {
    if (!vst[pp[now]]) Dfs(pp[now]);
  }
}
map<long long, long long> p;
signed main() {
  cin >> n;
  for (i = 1; i <= n; ++i)
    cin >> a[i].x >> a[i].y, a[i].pos = i, b[i] = a[i],
                             p[a[i].x * 2000000000ll + a[i].y] = 1;
  sort(a + 1, a + n + 1, cmp);
  sort(b + 1, b + n + 1, CMP);
  for (i = 1; i <= n; ++i) {
    if (a[i].x == a[i + 1].x) nxt[a[i].pos] = a[i + 1].pos;
  }
  s = 0;
  t = n + n + 1;
  for (i = 1; i <= n; ++i) ADD(s, i), ADD(n + i, t);
  for (i = 1; i <= n; ++i) {
    if (b[i].y == b[i + 1].y) {
      for (j = 1; j <= n; ++j)
        if (nxt[a[j].pos] && a[j].x < b[i + 1].x && a[j].x > b[i].x &&
            b[i].y > a[j].y && b[i].y < a[j + 1].y &&
            !p[a[j].x * 2000000000ll + b[i].y]) {
          ADD(a[j].pos, b[i].pos + n);
        }
    }
  }
  dinic();
  for (i = 1; i <= n; ++i) {
    for (j = node[i]; j; j = e[j].nxt) {
      if (e[j].to && e[j ^ 1].val) {
        pp[i] = e[j].to;
        vv[e[j].to] = 1;
      }
    }
  }
  for (i = n + 1; i <= n + n; ++i) {
    if (!vv[i] && !vst[i]) Dfs(i);
  }
  for (i = las = 1; i <= n; ++i) {
    if (b[i].y != b[i + 1].y || !vst[b[i].pos + n]) ++aaa;
  }
  cout << aaa << "\n";
  for (i = las = 1; i <= n; ++i) {
    if (b[i].y != b[i + 1].y || !vst[b[i].pos + n])
      cout << b[las].x << " " << b[las].y << " " << b[i].x << " " << b[i].y
           << "\n",
          las = i + 1;
  }
  aaa = 0;
  for (i = las = 1; i <= n; ++i) {
    if (a[i].x != a[i + 1].x || vst[a[i].pos]) ++aaa;
  }
  cout << aaa << "\n";
  for (i = las = 1; i <= n; ++i) {
    if (a[i].x != a[i + 1].x || vst[a[i].pos])
      cout << a[las].x << " " << a[las].y << " " << a[i].x << " " << a[i].y
           << "\n",
          las = i + 1;
  }
}
