Problem: Pasha is a young technician, nevertheless, he has already got a huge goal: to assemble a PC. The first task he has to become familiar with is to assemble an electric scheme.

The scheme Pasha assembled yesterday consists of several wires. Each wire is a segment that connects two points on a plane with integer coordinates within the segment [1, 10^9].

There are wires of two colors in the scheme: 

  * red wires: these wires are horizontal segments, i.e. if such a wire connects two points (x_1, y_1) and (x_2, y_2), then y_1 = y_2; 
  * blue wires: these wires are vertical segments, i.e. if such a wire connects two points (x_1, y_1) and (x_2, y_2), then x_1 = x_2. 



Note that if a wire connects a point to itself, it may be blue, and it can be red. Also, in Pasha's scheme no two wires of the same color intersect, i.e. there are no two wires of same color that have common points.

The imperfection of Pasha's scheme was that the wires were not isolated, so in the points where two wires of different colors intersect, Pasha saw sparks. Pasha wrote down all the points where he saw sparks and obtained a set of n distinct points. After that he disassembled the scheme.

Next morning Pasha looked at the set of n points where he had seen sparks and wondered how many wires had he used. Unfortunately, he does not remember that, so he wonders now what is the smallest number of wires he might have used in the scheme. Help him to determine this number and place the wires in such a way that in the resulting scheme the sparks occur in the same places.

Input

The first line contains a single integer n (1 ≤ n ≤ 1000) — the number of points where Pasha saw sparks.

Each of the next n lines contain two integers x and y (1 ≤ x, y ≤ 10^9) — the coordinates of a point with sparks. It is guaranteed that all points are distinct.

Output

Print the description of the scheme in the following format.

In the first line print h — the number of horizontal red wires (0 ≤ h). In each of the next h lines print 4 integers x_1, y_1, x_2, y_2 — the coordinates of two points (x_1, y_1) and (x_2, y_2) that are connected with this red wire. The segmenst must be horizontal, i.e. y_1 = y_2 must hold. Also, the constraint 1 ≤ x_1, y_1, x_2, y_2 ≤ 10^9 must hold.

After that print v — the number of vertical blue wires (0 ≤ v). In each of the next v lines print 4 integers x_1, y_1, x_2, y_2 — the coordinates of two points (x_1, y_1) and (x_2, y_2) that are connected with this blue wire. The segmenst must be vertical, i.e. x_1 = x_2 shomustuld hold. Also, the constraint 1 ≤ x_1, y_1, x_2, y_2 ≤ 10^9 must hold.

No two segments of the same color should have common points. The set of points where sparks appear should be the same as given in the input.

The number of segments (h + v) should be minimum possible. It's easy to see that the answer always exists. If there are multiple possible answers, print any.

Examples

Input

4
2 2
2 4
4 2
4 4


Output

2
5 2 1 2
1 4 5 4
2
2 1 2 5
4 5 4 1


Input

4
2 1
3 2
2 3
1 2


Output

4
2 1 2 1
3 2 3 2
1 2 1 2
2 3 2 3
3
1 2 1 2
3 2 3 2
2 3 2 1

Note

In the first example Pasha could have assembled the following scheme:

<image>

In this scheme there are 2 wires of each color: red ones connecting (5, 2) with (1, 2) and (1, 4) with (5, 4), blue ones connecting (2, 1) with (2, 5) and (4, 5) with (4, 1). Note that the sparks appear in the points that are described in the input, they are shown in yellow on the picture. For example, Pasha will see the spark in the point (2, 4) because the second red wire and the first blue wire intersect there. It is possible to show that we can't have less than 4 wires to produce a scheme with same sparks positions.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
const int FFTMOD = 119 << 23 | 1;
const int INF = (int)1e9 + 23111992;
const long long LINF = (long long)1e18 + 23111992;
const long double PI = acos((long double)-1);
const long double EPS = 1e-9;
inline long long gcd(long long a, long long b) {
  long long r;
  while (b) {
    r = a % b;
    a = b;
    b = r;
  }
  return a;
}
inline long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
inline long long fpow(long long n, long long k, int p = MOD) {
  long long r = 1;
  for (; k; k >>= 1) {
    if (k & 1) r = r * n % p;
    n = n * n % p;
  }
  return r;
}
template <class T>
inline int chkmin(T& a, const T& val) {
  return val < a ? a = val, 1 : 0;
}
template <class T>
inline int chkmax(T& a, const T& val) {
  return a < val ? a = val, 1 : 0;
}
inline unsigned long long isqrt(unsigned long long k) {
  unsigned long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline void addmod(int& a, int val, int p = MOD) {
  if ((a = (a + val)) >= p) a -= p;
}
inline void submod(int& a, int val, int p = MOD) {
  if ((a = (a - val)) < 0) a += p;
}
inline int mult(int a, int b, int p = MOD) { return (long long)a * b % p; }
inline int inv(int a, int p = MOD) { return fpow(a, p - 2, p); }
inline int sign(long double x) { return x < -EPS ? -1 : x > +EPS; }
inline int sign(long double x, long double y) { return sign(x - y); }
mt19937 mt(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int myrand() { return abs((int)mt()); }
struct HopcroftKarp {
  static const int maxv = 3e3 + 5;
  static const int maxe = 2e6 + 5;
  int nx, ny, E, adj[maxe], nxt[maxe], lst[maxv], ptr[maxv], lev[maxv],
      que[maxv], matx[maxv], maty[maxv];
  void init(int nx, int ny) {
    this->nx = nx, this->ny = ny;
    E = 0, fill_n(lst, nx, -1);
    fill_n(matx, nx, -1), fill_n(maty, ny, -1);
  }
  void add(int x, int y) { adj[E] = y, nxt[E] = lst[x], lst[x] = E++; }
  int bfs() {
    int qsize = 0;
    for (int x = 0; x < nx; x++)
      if (matx[x] != -1)
        lev[x] = 0;
      else {
        lev[x] = 1;
        que[qsize++] = x;
      }
    int found = 0;
    for (int i = 0; i < qsize; i++) {
      for (int x = que[i], e = lst[x]; ~e; e = nxt[e]) {
        int y = adj[e];
        if (!~maty[y])
          found = 1;
        else if (!lev[maty[y]]) {
          lev[maty[y]] = lev[x] + 1;
          que[qsize++] = maty[y];
        }
      }
    }
    return found;
  }
  int dfs(int x) {
    for (int& e = ptr[x]; ~e; e = nxt[e]) {
      int y = adj[e];
      if (!~maty[y] || (lev[maty[y]] == lev[x] + 1 && dfs(maty[y]))) {
        matx[x] = y;
        maty[y] = x;
        return 1;
      }
    }
    return 0;
  }
  int maxmat() {
    int res = 0;
    while (bfs()) {
      for (int x = 0; x < nx; x++) ptr[x] = lst[x];
      for (int x = 0; x < nx; x++)
        if (!~matx[x]) res += dfs(x);
    }
    return res;
  }
  int vis[2][maxv];
  void dfs(int u, int r) {
    vis[r][u] = 1;
    if (!r) {
      for (int e = lst[u]; ~e; e = nxt[e]) {
        int v = adj[e];
        if (matx[u] != v && !vis[!r][v]) {
          dfs(v, !r);
        }
      }
    } else {
      int v = maty[u];
      if (~v && !vis[!r][v]) {
        dfs(v, !r);
      }
    }
  }
  pair<vector<int>, vector<int> > mincover() {
    for (int u = (0); u < (nx); ++u)
      if (!~matx[u] && !vis[0][u]) {
        dfs(u, 0);
      }
    pair<vector<int>, vector<int> > res;
    for (int x = (0); x < (nx); ++x)
      if (!vis[0][x]) res.first.push_back(x);
    for (int y = (0); y < (ny); ++y)
      if (vis[1][y]) res.second.push_back(y);
    return res;
  }
} hopkarp;
const int maxn = 3000 + 5;
int n;
int x[maxn];
int y[maxn];
int f[maxn][maxn];
int idx[maxn][maxn];
int idy[maxn][maxn];
int gx[maxn];
int gy[maxn];
void chemthan() {
  cin >> n;
  vector<int> dcx, dcy;
  for (int i = (0); i < (n); ++i)
    cin >> x[i] >> y[i], dcx.push_back(x[i]), dcy.push_back(y[i]);
  sort((dcx).begin(), (dcx).end()),
      (dcx).erase(unique((dcx).begin(), (dcx).end()), (dcx).end());
  sort((dcy).begin(), (dcy).end()),
      (dcy).erase(unique((dcy).begin(), (dcy).end()), (dcy).end());
  int cx = int((dcx).size());
  int cy = int((dcy).size());
  for (int i = (0); i < (n); ++i) {
    x[i] = lower_bound((dcx).begin(), (dcx).end(), x[i]) - dcx.begin();
    y[i] = lower_bound((dcy).begin(), (dcy).end(), y[i]) - dcy.begin();
    f[x[i]][y[i]] = 1;
  }
  int cidx = 0;
  for (int i = (0); i < (cx); ++i) {
    for (int j = (0); j < (cy); ++j) {
      if (!f[i][j]) {
        int nj = j;
        while (nj < cy && !f[i][nj]) {
          idx[i][nj] = cidx;
          nj++;
        }
        if (!j || nj == cy) {
          gx[cidx] = 1;
        }
        j = nj - 1;
        cidx++;
      }
    }
  }
  int cidy = 0;
  for (int j = (0); j < (cy); ++j) {
    for (int i = (0); i < (cx); ++i) {
      if (!f[i][j]) {
        int ni = i;
        while (ni < cx && !f[ni][j]) {
          idy[ni][j] = cidy;
          ni++;
        }
        if (!i || ni == cx) {
          gy[cidy] = 1;
        }
        i = ni - 1;
        cidy++;
      }
    }
  }
  assert(cidx < 3000 && cidy < 3000);
  hopkarp.init(cidx, cidy);
  for (int i = (0); i < (cx); ++i)
    for (int j = (0); j < (cy); ++j) {
      if (!f[i][j] && !gx[idx[i][j]] && !gy[idy[i][j]]) {
        hopkarp.add(idx[i][j], idy[i][j]);
      }
    }
  int res = hopkarp.maxmat();
  pair<vector<int>, vector<int> > cover = hopkarp.mincover();
  assert(res == int((cover.first).size()) + int((cover.second).size()));
  for (int x : cover.first) {
    gx[x] = 1;
  }
  for (int y : cover.second) {
    gy[y] = 1;
  }
  vector<pair<int, pair<int, int> > > ver, hor;
  for (int x = (0); x < (cx); ++x) {
    for (int y = (0); y < (cy); ++y) {
      if (f[x][y]) {
        int ny = y;
        while (ny < cy && (f[x][ny] || !gx[idx[x][ny]])) ny++;
        ver.push_back(make_pair(x, make_pair(y, ny - 1)));
        y = ny - 1;
      }
    }
  }
  for (int y = (0); y < (cy); ++y) {
    for (int x = (0); x < (cx); ++x) {
      if (f[x][y]) {
        int nx = x;
        while (nx < cx && (f[nx][y] || !gy[idy[nx][y]])) nx++;
        hor.push_back(make_pair(y, make_pair(x, nx - 1)));
        x = nx - 1;
      }
    }
  }
  cout << int((hor).size()) << "\n";
  for (auto it : hor) {
    cout << dcx[it.second.first] << " " << dcy[it.first] << " "
         << dcx[it.second.second] << " " << dcy[it.first] << "\n";
  }
  cout << int((ver).size()) << "\n";
  for (auto it : ver) {
    cout << dcx[it.first] << " " << dcy[it.second.first] << " " << dcx[it.first]
         << " " << dcy[it.second.second] << "\n";
  }
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(0), cin.tie(0);
  if (argc > 1) {
    assert(freopen(argv[1], "r", stdin));
  }
  if (argc > 2) {
    assert(freopen(argv[2], "wb", stdout));
  }
  chemthan();
  cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}