#include <bits/stdc++.h>
using namespace std;
struct Maxflow {
  struct edge {
    int from, to;
    long long flow, capacity;
  };
  int s, t;
  vector<edge> edg;
  vector<int> g[3111];
  int dist[3111], visited[3111];
  int cur[3111];
  void init() {
    edg.clear();
    int i;
    for (i = 0; i < 3111; i++) {
      g[i].clear();
    }
  }
  void addedge(int from, int to, long long capacity) {
    edge e1 = edge{from, to, 0ll, capacity};
    edge e2 = edge{to, from, 0ll, 0ll};
    edg.push_back(e1), edg.push_back(e2);
    g[from].push_back((int)edg.size() - 2);
    g[to].push_back((int)edg.size() - 1);
  }
  bool bfs() {
    memset(visited, 0, sizeof(visited));
    memset(dist, 0, sizeof(dist));
    queue<int> q;
    q.push(s);
    visited[s] = 1;
    dist[s] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i = 0; i < (int)g[v].size(); i++) {
        edge &e = edg[g[v][i]];
        int nxt = e.to;
        if (!visited[nxt] && e.capacity > e.flow) {
          dist[nxt] = dist[v] + 1;
          q.push(nxt);
          visited[nxt] = 1;
        }
      }
    }
    return visited[t];
  }
  long long dfs(int x, long long cp) {
    if (x == t || cp == 0) {
      return cp;
    }
    long long flow = 0, newflow;
    for (int &y = cur[x]; y < (int)g[x].size(); y++) {
      edge &e = edg[g[x][y]];
      if (dist[x] + 1 == dist[e.to]) {
        long long minn = min(cp, e.capacity - e.flow);
        newflow = dfs(e.to, minn);
        if (newflow > 0) {
          e.flow += newflow;
          edg[g[x][y] ^ 1].flow -= newflow;
          flow += newflow;
          cp -= newflow;
          if (cp == 0) {
            break;
          }
        }
      }
    }
    return flow;
  }
  long long Dinic() {
    long long flow = 0;
    while (bfs()) {
      memset(cur, 0, sizeof(cur));
      flow += dfs(s, 10000000000ll);
    }
    return flow;
  }
};
Maxflow mf;
unordered_map<int, vector<int>> hz;
unordered_map<int, vector<int>> vc;
int tx[3111], ty[3111];
vector<pair<pair<int, int>, int>> hs, vs;
int x[3111], y[3111];
set<pair<pair<int, int>, int>> elih, eliv;
set<pair<int, int>> valid;
vector<pair<pair<int, int>, int>> ansh, ansv;
int visited[3111];
void dfs(int v) {
  visited[v] = 1;
  for (auto idx : mf.g[v]) {
    auto e = mf.edg[idx];
    if (e.flow != e.capacity && !visited[e.to]) {
      dfs(e.to);
    }
  }
}
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &tx[i], &ty[i]);
    hz[ty[i]].push_back(tx[i]);
    vc[tx[i]].push_back(ty[i]);
    x[i] = tx[i], y[i] = ty[i];
    valid.insert(make_pair(x[i], y[i]));
  }
  mf.s = 0, mf.t = 3111 - 1;
  auto iter = hz.begin();
  while (iter != hz.end()) {
    sort(iter->second.begin(), iter->second.end());
    for (i = 1; i < (int)iter->second.size(); ++i) {
      hs.push_back(make_pair(make_pair(iter->second[i - 1], iter->second[i]),
                             iter->first));
    }
    ++iter;
  }
  iter = vc.begin();
  while (iter != vc.end()) {
    sort(iter->second.begin(), iter->second.end());
    for (i = 1; i < (int)iter->second.size(); ++i) {
      vs.push_back(make_pair(make_pair(iter->second[i - 1], iter->second[i]),
                             iter->first));
    }
    ++iter;
  }
  int sz1 = hs.size(), sz2 = vs.size();
  for (i = 1; i <= sz1; ++i) {
    mf.addedge(mf.s, i, 1);
  }
  for (i = 1; i <= sz2; ++i) {
    mf.addedge(i + sz1, mf.t, 1);
  }
  for (i = 1; i <= sz1; ++i) {
    for (j = 1; j <= sz2; ++j) {
      auto p1 = hs[i - 1], p2 = vs[j - 1];
      int x1 = p1.first.first, x2 = p1.first.second, y = p1.second;
      int y1 = p2.first.first, y2 = p2.first.second, x = p2.second;
      if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
        if (valid.find(make_pair(x, y)) == valid.end()) {
          mf.addedge(i, j + sz1, 10000000000ll);
        }
      }
    }
  }
  mf.Dinic();
  dfs(mf.s);
  for (auto e : mf.edg) {
    if (visited[e.from] && !visited[e.to]) {
      if (e.from == mf.s && e.to <= sz1 && e.flow == e.capacity) {
        elih.insert(hs[e.to - 1]);
      }
      if (e.to == mf.t && e.from > sz1 && e.flow == e.capacity) {
        eliv.insert(vs[e.from - sz1 - 1]);
      }
    }
  }
  iter = hz.begin();
  while (iter != hz.end()) {
    int low = iter->second[0], high = iter->second[0], y = iter->first;
    for (i = 0; i < (int)iter->second.size() - 1; ++i) {
      int x1 = iter->second[i], x2 = iter->second[i + 1];
      if (elih.find(make_pair(make_pair(x1, x2), y)) == elih.end()) {
        high = x2;
      } else {
        ansh.push_back(make_pair(make_pair(low, high), y));
        low = x2, high = x2;
      }
    }
    ansh.push_back(make_pair(make_pair(low, high), y));
    ++iter;
  }
  iter = vc.begin();
  while (iter != vc.end()) {
    int low = iter->second[0], high = iter->second[0], y = iter->first;
    for (i = 0; i < (int)iter->second.size() - 1; ++i) {
      int x1 = iter->second[i], x2 = iter->second[i + 1];
      if (eliv.find(make_pair(make_pair(x1, x2), y)) == eliv.end()) {
        high = x2;
      } else {
        ansv.push_back(make_pair(make_pair(low, high), y));
        low = x2, high = x2;
      }
    }
    ansv.push_back(make_pair(make_pair(low, high), y));
    ++iter;
  }
  printf("%d\n", (int)ansh.size());
  for (auto p : ansh) {
    printf("%d %d %d %d\n", p.first.first, p.second, p.first.second, p.second);
  }
  printf("%d\n", (int)ansv.size());
  for (auto p : ansv) {
    printf("%d %d %d %d\n", p.second, p.first.first, p.second, p.first.second);
  }
  return 0;
}
