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;
vector<int> match;
vector<bool> seen;
bool find(int j, const vector<vector<int> >& g) {
  if (match[j] == -1) return 1;
  seen[j] = 1;
  int di = match[j];
  for (auto& e : g[di])
    if (!seen[e] && find(e, g)) {
      match[e] = di;
      return 1;
    }
  return 0;
}
int dfs_matching(const vector<vector<int> >& g, int n, int m) {
  match.assign(m, -1);
  for (int i = 0; i < (n); ++i) {
    seen.assign(m, 0);
    for (auto& j : g[i])
      if (find(j, g)) {
        match[j] = i;
        break;
      }
  }
  return m - (int)count(match.begin(), match.end(), -1);
}
vector<int> cover(vector<vector<int> >& g, int n, int m) {
  int res = dfs_matching(g, n, m);
  seen.assign(m, false);
  vector<bool> lfound(n, true);
  for (auto& it : match)
    if (it != -1) lfound[it] = false;
  vector<int> q, cover;
  for (int i = 0; i < (n); ++i)
    if (lfound[i]) q.push_back(i);
  while (!q.empty()) {
    int i = q.back();
    q.pop_back();
    lfound[i] = 1;
    for (auto& e : g[i])
      if (!seen[e] && match[e] != -1) {
        seen[e] = true;
        q.push_back(match[e]);
      }
  }
  for (int i = 0; i < (n); ++i)
    if (!lfound[i]) cover.push_back(i);
  for (int i = 0; i < (m); ++i)
    if (seen[i]) cover.push_back(n + i);
  assert((int)(cover).size() == res);
  return cover;
}
struct step {
  int a, b, c, d;
  step(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
};
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<int, int> > pts(n);
  set<int> xr;
  set<int> yr;
  for (int i = 0; i < n; i++) {
    cin >> pts[i].first >> pts[i].second;
    xr.insert(pts[i].first);
    yr.insert(pts[i].second);
  }
  map<int, int> xz;
  map<int, int> xinvz;
  for (int a : xr) {
    int k = xz.size();
    xz[a] = k;
    xinvz[k] = a;
  }
  map<int, int> yz;
  map<int, int> yinvz;
  for (int a : yr) {
    int k = yz.size();
    yz[a] = k;
    yinvz[k] = a;
  }
  int nrows = xr.size();
  int ncols = yr.size();
  vector<vector<int> > rownum(nrows, vector<int>(ncols, -1));
  vector<vector<int> > colnum(nrows, vector<int>(ncols, -1));
  vector<vector<int> > rows(nrows);
  vector<vector<int> > cols(ncols);
  for (int i = 0; i < n; i++) {
    pts[i].first = xz[pts[i].first];
    pts[i].second = yz[pts[i].second];
    rows[pts[i].first].push_back(pts[i].second);
    cols[pts[i].second].push_back(pts[i].first);
  }
  vector<step> rsegs;
  for (int i = 0; i < nrows; i++) {
    sort(rows[i].begin(), rows[i].end());
    for (int a = 0; a + 1 < rows[i].size(); a++) {
      int id = rsegs.size();
      rsegs.push_back(step(i, rows[i][a], i, rows[i][a + 1]));
      for (int b = rows[i][a] + 1; b <= rows[i][a + 1] - 1; b++) {
        rownum[i][b] = id;
      }
    }
  }
  vector<step> csegs;
  for (int i = 0; i < ncols; i++) {
    sort(cols[i].begin(), cols[i].end());
    for (int a = 0; a + 1 < cols[i].size(); a++) {
      int id = csegs.size();
      csegs.push_back(step(cols[i][a], i, cols[i][a + 1], i));
      for (int b = cols[i][a] + 1; b <= cols[i][a + 1] - 1; b++) {
        colnum[b][i] = id;
      }
    }
  }
  vector<vector<int> > graph(rsegs.size());
  for (int i = 0; i < nrows; i++) {
    for (int j = 0; j < ncols; j++) {
      if (rownum[i][j] == -1) continue;
      if (colnum[i][j] == -1) continue;
      graph[rownum[i][j]].push_back(colnum[i][j]);
    }
  }
  vector<int> vc = cover(graph, rsegs.size(), csegs.size());
  vector<int> used(rsegs.size() + csegs.size(), 0);
  for (int a : vc) {
    used[a] = 1;
  }
  set<pair<pair<int, int>, pair<int, int> > > rmerge, cmerge;
  for (int a = 0; a < rsegs.size(); a++) {
    if (used[a] == 0) {
      step x = rsegs[a];
      rmerge.insert({{x.a, x.b}, {x.c, x.d}});
    }
  }
  for (int a = 0; a < csegs.size(); a++) {
    if (used[rsegs.size() + a] == 0) {
      step x = csegs[a];
      cmerge.insert({{x.a, x.b}, {x.c, x.d}});
    }
  }
  vector<step> rowans;
  vector<step> colans;
  for (int i = 0; i < nrows; i++) {
    int b = 0;
    while (b < rows[i].size()) {
      int c = b;
      while (c + 1 < rows[i].size() &&
             rmerge.find({{i, rows[i][c]}, {i, rows[i][c + 1]}}) !=
                 rmerge.end()) {
        c++;
      }
      rowans.push_back(step(i, rows[i][b], i, rows[i][c]));
      b = c + 1;
    }
  }
  for (int i = 0; i < ncols; i++) {
    int b = 0;
    while (b < cols[i].size()) {
      int c = b;
      while (c + 1 < cols[i].size() &&
             cmerge.find({{cols[i][c], i}, {cols[i][c + 1], i}}) !=
                 cmerge.end()) {
        c++;
      }
      colans.push_back(step(cols[i][b], i, cols[i][c], i));
      b = c + 1;
    }
  }
  cout << colans.size() << endl;
  for (int a = 0; a < colans.size(); a++) {
    step x = colans[a];
    cout << xinvz[x.a] << " " << yinvz[x.b] << " " << xinvz[x.c] << " "
         << yinvz[x.d] << '\n';
  }
  cout << rowans.size() << '\n';
  for (int a = 0; a < rowans.size(); a++) {
    step x = rowans[a];
    cout << xinvz[x.a] << " " << yinvz[x.b] << " " << xinvz[x.c] << " "
         << yinvz[x.d] << '\n';
  }
}