#include <bits/stdc++.h>
using namespace std;
const int N = 2010;
vector<int> G[N];
int n, a, b;
bool vis[N], use[N];
int match[N];
struct Point {
  int x, y;
} P[N];
bool cmpx(Point A, Point B) { return A.x == B.x ? A.y < B.y : A.x < B.x; }
bool cmpy(Point A, Point B) { return A.y == B.y ? A.x < B.x : A.y < B.y; }
struct Seg {
  int x, l, r;
} A[N], B[N];
bool Hungary(int o) {
  vis[o] = true;
  for (int v : G[o])
    if (!match[v] || (!vis[match[v]] && Hungary(match[v]))) {
      match[v] = o, match[o] = v;
      return true;
    }
  return false;
}
void DFS(int o) {
  if (vis[o]) return;
  use[o] = vis[o] = true;
  for (int v : G[o]) {
    vis[v] = true;
    DFS(match[v]);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &P[i].x, &P[i].y);
  sort(P + 1, P + n + 1, cmpx);
  for (int i = 2; i <= n; i++)
    if (P[i].x == P[i - 1].x) A[++a] = (Seg){P[i].x, P[i - 1].y, P[i].y};
  sort(P + 1, P + n + 1, cmpy);
  for (int i = 2; i <= n; i++)
    if (P[i].y == P[i - 1].y) B[++b] = (Seg){P[i].y, P[i - 1].x, P[i].x};
  for (int i = 1; i <= a; i++)
    for (int j = 1; j <= b; j++)
      if (A[i].l < B[j].x && B[j].x < A[i].r && B[j].l < A[i].x &&
          A[i].x < B[j].r)
        G[i].push_back(a + j), G[a + j].push_back(i);
  int cnt = 0;
  for (int i = 1; i <= a; i++)
    if (!match[i]) {
      memset(vis, 0, sizeof vis);
      cnt += Hungary(i);
    }
  memset(vis, 0, sizeof vis);
  for (int i = 1; i <= a + b; i++)
    if (!match[i]) DFS(i);
  for (int i = 1; i <= a + b; i++)
    if (!vis[i]) DFS(i);
  int ans = n;
  for (int i = 1; i <= b; i++)
    if (use[a + i]) --ans;
  printf("%d\n", ans);
  sort(P + 1, P + n + 1, cmpy);
  b = 0;
  for (int i = 1; i <= n; i++) {
    int r = i;
    while (P[r + 1].y == P[i].y && use[++b + a]) ++r;
    printf("%d %d %d %d\n", P[i].x, P[i].y, P[r].x, P[r].y);
    i = r;
  }
  ans = n;
  for (int i = 1; i <= a; i++)
    if (use[i]) --ans;
  printf("%d\n", ans);
  sort(P + 1, P + n + 1, cmpx);
  a = 0;
  for (int i = 1; i <= n; i++) {
    int r = i;
    while (P[r + 1].x == P[i].x && use[++a]) ++r;
    printf("%d %d %d %d\n", P[i].x, P[i].y, P[r].x, P[r].y);
    i = r;
  }
  return 0;
}
