#include <bits/stdc++.h>
using namespace std;
const int N = 1005;
void read(int &x) {
  x = 0;
  char ch = getchar();
  int f = 1;
  while (!isdigit(ch)) (ch == '-' ? f = -1 : 0), ch = getchar();
  while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
  x *= f;
}
struct xx {
  int x, l, r;
} a[N], b[N];
vector<int> e[N];
int bo[N], n, c1, c2, x, y, mat[N], vis[N], m[N];
map<int, multiset<int> > f, g;
int dfs(int x) {
  for (int i : e[x])
    if (!vis[i]) {
      vis[i] = 1;
      if (!mat[i] || dfs(mat[i])) {
        mat[i] = x, m[x] = i;
        return 1;
      }
    }
  return 0;
}
int q[N];
signed main() {
  read(n);
  for (int i = 1; i <= n; ++i) read(x), read(y), f[x].insert(y), g[y].insert(x);
  for (auto &i : f) {
    auto j = i.second.begin();
    int x = *j;
    while (++j != i.second.end())
      a[++c1] = (xx){i.first, x, *j}, i.second.insert(x), x = *j;
    i.second.insert(x);
  }
  for (auto &i : g) {
    auto j = i.second.begin();
    int x = *j;
    while (++j != i.second.end())
      b[++c2] = (xx){i.first, x, *j}, i.second.insert(x), x = *j;
    i.second.insert(x);
  }
  for (int i = 1; i <= c1; ++i)
    for (int j = 1; j <= c2; ++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)
        e[i].push_back(j);
  for (int i = 1; i <= c1; ++i)
    if (!m[i]) dfs(i), memset(vis, 0, sizeof(vis));
  int r = 0;
  for (int i = 1; i <= c1; ++i)
    if (!m[i]) q[++r] = i;
  for (int l = 1; l <= r; ++l) {
    int x = q[l];
    for (int i : e[x])
      if (!vis[i]) {
        vis[i] = 1;
        if (m[mat[i]]) m[mat[i]] = 0, q[++r] = mat[i];
      }
  }
  int h = n, v = n, o = 0;
  for (int i = 1; i <= c1; ++i)
    if (!m[i])
      f[a[i].x].erase(f[a[i].x].find(a[i].l)),
          f[a[i].x].erase(f[a[i].x].find(a[i].r)), --h;
  for (int i = 1; i <= c2; ++i)
    if (!vis[i])
      g[b[i].x].erase(g[b[i].x].find(b[i].l)),
          g[b[i].x].erase(g[b[i].x].find(b[i].r)), --v;
  printf("%d\n", v);
  for (auto &i : g)
    for (int j : i.second)
      printf("%d %d%c", j, i.first, o ? '\n' : ' '), o ^= 1;
  printf("%d\n", h);
  for (auto &i : f)
    for (int j : i.second)
      printf("%d %d%c", i.first, j, o ? '\n' : ' '), o ^= 1;
  return 0;
}
