#include <bits/stdc++.h>
using namespace std;
int main() {
  cout.precision(30);
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<long long, long long>> ps(n);
  for (int i = 0; i < n; i++) {
    cin >> ps[i].first >> ps[i].second;
  }
  sort(ps.begin(), ps.end(),
       [&](pair<long long, long long> a, pair<long long, long long> b) {
         return make_pair(a.second, a.first) < make_pair(b.second, b.first);
       });
  vector<long long> hadv(n, 0), hadh(n, 0);
  vector<pair<long long, long long>> v, h;
  vector<pair<pair<long long, long long>, pair<long long, long long>>> verts;
  long long cury = ps[0].second;
  for (int i = 1; i < n; i++) {
    if (cury != ps[i].second) {
      cury = ps[i].second;
    } else {
      hadv[i - 1] = 1;
      hadv[i] = 1;
      verts.push_back({ps[i - 1], ps[i]});
    }
  }
  for (int i = 0; i < n; i++) {
    if (!hadv[i]) v.push_back(ps[i]), v.push_back(ps[i]);
  }
  sort(ps.begin(), ps.end());
  vector<pair<pair<long long, long long>, pair<long long, long long>>> hors;
  long long curx = ps[0].first;
  for (int i = 1; i < n; i++) {
    if (curx != ps[i].first) {
      curx = ps[i].first;
    } else {
      hadh[i - 1] = 1;
      hadh[i] = 1;
      hors.push_back({ps[i - 1], ps[i]});
    }
  }
  for (int i = 0; i < n; i++) {
    if (!hadh[i]) h.push_back(ps[i]), h.push_back(ps[i]);
  }
  swap(hors, verts);
  swap(h, v);
  auto inter = [&](pair<long long, long long> a, pair<long long, long long> b,
                   pair<long long, long long> c, pair<long long, long long> d) {
    if (c.first < a.first && a.first < d.first) {
      if (a.second < c.second && c.second < b.second) return true;
    }
    return false;
  };
  vector<vector<long long>> g(verts.size());
  for (int i = 0; i < verts.size(); i++) {
    for (int j = 0; j < hors.size(); j++) {
      if (inter(verts[i].first, verts[i].second, hors[j].first, hors[j].second))
        g[i].push_back(j);
    }
  }
  vector<long long> to(hors.size(), -1);
  vector<long long> used(verts.size(), 0);
  vector<long long> from(verts.size(), -1);
  function<bool(int)> dfs = [&](int v) {
    if (used[v]) return false;
    used[v] = 1;
    for (int u : g[v]) {
      if (to[u] == -1 || dfs(to[u])) {
        to[u] = v;
        from[v] = u;
        return true;
      }
    }
    return false;
  };
  for (int i = 0; i < verts.size(); i++) {
    used.assign(verts.size(), 0);
    dfs(i);
  }
  used.assign(verts.size(), 0);
  vector<long long> used1(hors.size(), 0);
  function<void(int)> dfs1 = [&](int v) {
    if (used[v]) return;
    used[v] = 1;
    for (int u : g[v]) {
      if (!used1[u]) {
        used1[u] = 1;
        dfs1(to[u]);
      }
    }
  };
  vector<long long> free(verts.size(), 1);
  for (int i : to)
    if (i != -1) free[i] = 0;
  for (int i = 0; i < verts.size(); i++)
    if (free[i]) dfs1(i);
  for (int i = 0; i < verts.size(); i++) {
    auto a = verts[i].first, b = verts[i].second;
    if (i == 0 || verts[i - 1].second != verts[i].first) {
      if (i > 0) v.push_back(verts[i - 1].second);
      v.push_back(a);
    }
    if (!used[i]) v.push_back(a), v.push_back(b);
  }
  if (!verts.empty()) v.push_back(verts.back().second);
  for (int i = 0; i < hors.size(); i++) {
    auto a = hors[i].first, b = hors[i].second;
    if (i == 0 || hors[i - 1].second != hors[i].first) {
      if (i > 0) h.push_back(hors[i - 1].second);
      h.push_back(a);
    }
    if (used1[i]) h.push_back(a), h.push_back(b);
  }
  if (!hors.empty()) h.push_back(hors.back().second);
  cout << h.size() / 2 << endl;
  for (int i = 0; i < h.size(); i++)
    cout << h[i].first << ' ' << h[i].second << ((i % 2) ? '\n' : ' ');
  cout << v.size() / 2 << endl;
  for (int i = 0; i < v.size(); i++)
    cout << v[i].first << ' ' << v[i].second << ((i % 2) ? '\n' : ' ');
  return 0;
}
