#include <bits/stdc++.h>
using namespace std;
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() {
  rnd_data = rnd_data * 0x5DEECE66DULL + 0xB;
  return (rnd_data >> 17) & 0x7FFFFFFF;
}
template <typename T>
void my_random_shuffle(T b, T e) {
  for (int i = (1); i <= (int)((int)(e - b) - 1); i++) {
    swap(b[i], b[my_rand() % (i + 1)]);
  }
}
template <class _T>
inline _T sqr(const _T &x) {
  return x * x;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uin(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(b, a) ? a = b, true : false;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uax(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(a, b) ? a = b, true : false;
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-9;
struct tp {
  int x, y;
};
int n, xx = 0, yy = 0;
tp p[1024];
int xs[1024];
int ys[1024];
bool b[1024][1024];
int xr[1024][2];
int yr[1024][2];
int kh, kv;
int nh[1024][1024];
int nv[1024][1024];
vector<int> a[10240];
vector<int> ra[10240];
bool u[10240];
int p1[10240];
int pa[10240];
bool u2[10240];
int ah[10240][4];
int av[10240][4];
bool bh[1024][1024];
bool bv[1024][1024];
bool find(int k) {
  u[k] = true;
  for (int v : a[k]) {
    if (pa[v] == -1) {
      pa[v] = k;
      return true;
    }
  }
  for (int v : a[k]) {
    if (pa[v] == -1 || (!u[pa[v]] && find(pa[v]))) {
      pa[v] = k;
      return true;
    }
  }
  return false;
}
void dfs(int k) {
  u[k] = true;
  for (int v : a[k]) {
    if (pa[v] == k) continue;
    if (!u2[v]) {
      u2[v] = true;
      dfs(pa[v]);
    }
  }
}
void solve() {
  memset(p1, 0xff, sizeof(p1));
  for (int i = 0; i < (int)(kv); i++) {
    if (pa[i] != -1) {
      p1[pa[i]] = i;
    }
  }
  memset((u), 0, sizeof(u));
  memset((u2), 0, sizeof(u2));
  for (int i = 0; i < (int)(kh); i++) {
    if (p1[i] == -1) {
      dfs(i);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    xs[xx++] = p[i].x;
    ys[yy++] = p[i].y;
  }
  sort(xs, xs + xx);
  xx = unique(xs, xs + xx) - xs;
  sort(ys, ys + yy);
  yy = unique(ys, ys + yy) - ys;
  for (int i = 0; i < (int)(n); i++) {
    p[i].x = lower_bound(xs, xs + xx, p[i].x) - xs;
    p[i].y = lower_bound(ys, ys + yy, p[i].y) - ys;
  }
  memset((b), 0, sizeof(b));
  for (int i = 0; i < (int)(n); i++) {
    b[p[i].x][p[i].y] = true;
  }
  for (int j = 0; j < (int)(yy); j++) {
    yr[j][0] = xx + 1;
    yr[j][1] = -1;
  }
  for (int i = 0; i < (int)(xx); i++) {
    xr[i][0] = yy + 1;
    xr[i][1] = -1;
    for (int j = 0; j < (int)(yy); j++) {
      if (b[i][j]) {
        uin(xr[i][0], j);
        uax(xr[i][1], j);
        uin(yr[j][0], i);
        uax(yr[j][1], i);
      }
    }
  }
  memset(nh, 0xff, sizeof(nh));
  memset(nv, 0xff, sizeof(nv));
  kh = kv = 0;
  for (int i = 0; i < (int)(xx); i++) {
    if (xr[i][1] < 0) continue;
    int sty = -1;
    for (int j = 0; j < (int)(yy); j++) {
      if (j < xr[i][0] || j > xr[i][1]) continue;
      if (b[i][j]) {
        if (sty != -1) {
          kh++;
          sty = -1;
        }
      } else {
        nh[i][j] = kh;
        sty = j;
      }
    }
    if (sty != -1) {
      kh++;
    }
  }
  for (int j = 0; j < (int)(yy); j++) {
    if (yr[j][1] < 0) continue;
    int stx = -1;
    for (int i = 0; i < (int)(xx); i++) {
      if (i < yr[j][0] || i > yr[j][1]) continue;
      if (b[i][j]) {
        if (stx != -1) {
          kv++;
          stx = -1;
        }
      } else {
        nv[i][j] = kv;
        stx = i;
      }
    }
    if (stx != -1) {
      kv++;
    }
  }
  for (int i = 0; i < (int)(xx); i++) {
    for (int j = 0; j < (int)(yy); j++) {
      if (nh[i][j] != -1) {
        if (nv[i][j] != -1) {
          a[nh[i][j]].push_back(nv[i][j]);
          ra[nv[i][j]].push_back(nh[i][j]);
        }
      }
    }
  }
  memset(pa, 0xff, sizeof(pa));
  memset((u), 0, sizeof(u));
  for (int i = 0; i < (int)(kh); i++) {
    if (find(i)) {
      memset(u, 0, kh * sizeof(u[0]));
    }
  }
  memcpy(bh, b, sizeof(b));
  memcpy(bv, b, sizeof(b));
  solve();
  for (int i = 0; i < (int)(xx); i++) {
    for (int j = 0; j < (int)(yy); j++) {
      if (nh[i][j] >= 0 && u[nh[i][j]]) bh[i][j] = true;
      if (nv[i][j] >= 0 && !u2[nv[i][j]]) bv[i][j] = true;
    }
  }
  int hh = 0, vv = 0;
  for (int i = 0; i < (int)(xx); i++) {
    if (xr[i][1] < 0) continue;
    int st = -1;
    for (int j = 0; j < (int)(yy + 1); j++) {
      if (bh[i][j]) {
        if (st < 0) st = j;
      } else {
        if (st >= 0) {
          ah[hh][0] = i;
          ah[hh][1] = st;
          ah[hh][2] = i;
          ah[hh][3] = j - 1;
          hh++;
          st = -1;
        }
      }
    }
  }
  for (int j = 0; j < (int)(yy); j++) {
    if (yr[j][1] < 0) continue;
    int st = -1;
    for (int i = 0; i < (int)(xx + 1); i++) {
      if (bv[i][j]) {
        if (st < 0) st = i;
      } else {
        if (st >= 0) {
          av[vv][0] = st;
          av[vv][1] = j;
          av[vv][2] = i - 1;
          av[vv][3] = j;
          vv++;
          st = -1;
        }
      }
    }
  }
  printf("%d\n", vv);
  for (int i = 0; i < (int)(vv); i++) {
    for (int j = 0; j < (int)(2); j++) {
      printf("%d %d%c", xs[av[i][j * 2]], ys[av[i][j * 2 + 1]], " \n"[j == 1]);
    }
  }
  printf("%d\n", hh);
  for (int i = 0; i < (int)(hh); i++) {
    for (int j = 0; j < (int)(2); j++) {
      printf("%d %d%c", xs[ah[i][j * 2]], ys[ah[i][j * 2 + 1]], " \n"[j == 1]);
    }
  }
  return 0;
}
