#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
struct Section {
  int l, r, pos;
  Section(int _l = 0, int _r = 0, int _pos = 0) : l(_l), r(_r), pos(_pos) {}
  inline bool operator<(const Section& rhs) const {
    if (l != rhs.l) return l < rhs.l;
    if (r != rhs.r) return r < rhs.r;
    return pos < rhs.pos;
  }
};
struct Segment {
  int x, y, x2, y2;
  Segment(int _x = 0, int _y = 0, int _x2 = 0, int _y2 = 0)
      : x(_x), y(_y), x2(_x2), y2(_y2) {}
};
vector<Segment> ans_h, ans_v;
vector<int> xs, ys, vx[maxn], vy[maxn], dx[maxn], dy[maxn];
pair<int, int> pt[maxn];
vector<Section> sec_x, sec_y;
vector<int> g[maxn];
bool vis[maxn];
int x_match[maxn], y_match[maxn];
bool dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    if (!y_match[v] || (!vis[y_match[v]] && dfs(y_match[v]))) {
      x_match[u] = v;
      y_match[v] = u;
      return true;
    }
  }
  return false;
}
bool mark_x[maxn], mark_y[maxn];
void dfs_sec(int u) {
  mark_x[u] = false;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    mark_y[v] = true;
    if (y_match[v] && mark_x[y_match[v]]) {
      dfs_sec(y_match[v]);
    }
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    xs.push_back(x);
    ys.push_back(y);
    pt[i] = pair<int, int>(x, y);
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  sort(ys.begin(), ys.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  for (int i = 1; i <= n; i++) {
    pt[i].first =
        lower_bound(xs.begin(), xs.end(), pt[i].first) - xs.begin() + 1;
    pt[i].second =
        lower_bound(ys.begin(), ys.end(), pt[i].second) - ys.begin() + 1;
    vx[pt[i].first].push_back(pt[i].second);
    vy[pt[i].second].push_back(pt[i].first);
  }
  for (int i = 1; i <= (int)xs.size(); i++) {
    sort(vx[i].begin(), vx[i].end());
    for (int j = 1; j < (int)vx[i].size(); j++)
      sec_x.push_back(Section(vx[i][j - 1], vx[i][j], i));
  }
  for (int i = 1; i <= (int)ys.size(); i++) {
    sort(vy[i].begin(), vy[i].end());
    for (int j = 1; j < (int)vy[i].size(); j++)
      sec_y.push_back(Section(vy[i][j - 1], vy[i][j], i));
  }
  sort(sec_x.begin(), sec_x.end());
  sort(sec_y.begin(), sec_y.end());
  for (int i = 0; i < (int)sec_x.size(); i++) {
    for (int j = 0; j < (int)sec_y.size(); j++) {
      bool found = true;
      if (sec_x[i].r <= sec_y[j].pos || sec_x[i].l >= sec_y[j].pos)
        found = false;
      if (sec_y[j].r <= sec_x[i].pos || sec_y[j].l >= sec_x[i].pos)
        found = false;
      if (found) g[i + 1].push_back(j + 1);
    }
  }
  for (int i = 1; i <= (int)sec_x.size(); i++) {
    memset(vis, 0, sizeof vis);
    dfs(i);
    mark_x[i] = true;
  }
  for (int i = 1; i <= (int)sec_x.size(); i++)
    if (!x_match[i]) dfs_sec(i);
  for (int i = 1; i <= (int)ys.size(); i++)
    if (vy[i].size() >= 1) dy[i].push_back(vy[i][0]);
  for (int i = 1; i <= (int)xs.size(); i++)
    if (vx[i].size() >= 1) dx[i].push_back(vx[i][0]);
  for (int i = 1; i <= (int)sec_y.size(); i++)
    if (mark_y[i]) {
      dy[sec_y[i - 1].pos].push_back(sec_y[i - 1].l);
      dy[sec_y[i - 1].pos].push_back(sec_y[i - 1].r);
    }
  for (int i = 1; i <= (int)sec_x.size(); i++)
    if (mark_x[i]) {
      dx[sec_x[i - 1].pos].push_back(sec_x[i - 1].l);
      dx[sec_x[i - 1].pos].push_back(sec_x[i - 1].r);
    }
  for (int i = 1; i <= (int)ys.size(); i++)
    if (vy[i].size() >= 1) dy[i].push_back(vy[i].back());
  for (int i = 1; i <= (int)xs.size(); i++)
    if (vx[i].size() >= 1) dx[i].push_back(vx[i].back());
  int ans = 0;
  for (int i = 1; i <= (int)ys.size(); i++) ans += dy[i].size();
  printf("%d\n", ans >> 1);
  for (int i = 1; i <= (int)ys.size(); i++)
    for (int j = 0; j < (int)dy[i].size(); j += 2)
      printf("%d %d %d %d\n", xs[dy[i][j] - 1], ys[i - 1], xs[dy[i][j + 1] - 1],
             ys[i - 1]);
  ans = 0;
  for (int i = 1; i <= (int)xs.size(); i++) ans += dx[i].size();
  printf("%d\n", ans >> 1);
  for (int i = 1; i <= (int)xs.size(); i++)
    for (int j = 0; j < (int)dx[i].size(); j += 2)
      printf("%d %d %d %d\n", xs[i - 1], ys[dx[i][j] - 1], xs[i - 1],
             ys[dx[i][j + 1] - 1]);
  return 0;
}
