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>
#pragma GCC optimize "-O3"
using namespace std;
const int MAXN = 2200;
int n;
int x[MAXN];
int y[MAXN];
vector<int> vx, vy;
int fnd(const vector<int> &v, int x) {
  return lower_bound((v).begin(), (v).end(), x) - v.begin();
}
vector<int> gx[MAXN];
vector<int> gy[MAXN];
vector<int> eds[MAXN];
int p[MAXN];
int q[MAXN];
int was[MAXN];
int was1[MAXN];
int dfs1(int v) {
  was[v] = 1;
  for (int u : eds[v]) {
    if (q[u] == -1) {
      p[v] = u;
      q[u] = v;
      return 1;
    }
  }
  for (int u : eds[v]) {
    int x = q[u];
    if (!was[x] && dfs1(x)) {
      q[u] = v;
      p[v] = u;
      return 1;
    }
  }
  return 0;
}
void dfs2(int v) {
  was[v] = 1;
  for (int u : eds[v]) {
    if (!was1[u]) {
      was1[u] = 1;
      int x = q[u];
      if (x != -1 && !was[x]) dfs2(x);
    }
  }
}
vector<pair<int, int>> ax[MAXN], ay[MAXN];
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> y[i];
    swap(x[i], y[i]);
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  sort((vx).begin(), (vx).end());
  vx.resize(unique((vx).begin(), (vx).end()) - vx.begin());
  sort((vy).begin(), (vy).end());
  vy.resize(unique((vy).begin(), (vy).end()) - vy.begin());
  for (int i = 0; i < n; ++i) x[i] = fnd(vx, x[i]);
  for (int i = 0; i < n; ++i) y[i] = fnd(vy, y[i]);
  for (int i = 0; i < n; ++i) {
    gx[x[i]].push_back(y[i]);
    gy[y[i]].push_back(x[i]);
  }
  for (int i = 0; i < n; ++i)
    sort((gx[i]).begin(), (gx[i]).end()), sort((gy[i]).begin(), (gy[i]).end());
  vector<tuple<int, int, int>> ex, ey;
  for (int i = 0; i < vx.size(); ++i) {
    for (int j = 0; j + 1 < gx[i].size(); ++j) {
      ex.emplace_back(i, gx[i][j], gx[i][j + 1]);
    }
  }
  for (int i = 0; i < vy.size(); ++i) {
    for (int j = 0; j + 1 < gy[i].size(); ++j) {
      ey.emplace_back(i, gy[i][j], gy[i][j + 1]);
    }
  }
  for (int i = 0; i < ex.size(); ++i)
    for (int j = 0; j < ey.size(); ++j) {
      int a1, b1, c1;
      int a2, b2, c2;
      tie(a1, b1, c1) = ex[i];
      tie(a2, b2, c2) = ey[j];
      if (b2 < a1 && a1 < c2 && b1 < a2 && a2 < c1) {
        eds[i].push_back(j);
      }
    }
  memset(p, -1, sizeof(p));
  memset(q, -1, sizeof(q));
  int fl = 1;
  while (fl) {
    fl = 0;
    memset(was, 0, sizeof(was));
    for (int i = 0; i < ex.size(); ++i) {
      if (p[i] == -1 && !was[i] && dfs1(i)) fl = 1;
    }
  }
  memset(was, 0, sizeof(was));
  memset(was1, 0, sizeof(was1));
  for (int i = 0; i < ex.size(); ++i) {
    if (p[i] == -1) {
      dfs2(i);
    }
  }
  for (int i = 0; i < ex.size(); ++i) {
    if (was[i]) {
      int a, b, c;
      tie(a, b, c) = ex[i];
      ax[a].emplace_back(b, c);
    }
  }
  for (int i = 0; i < ey.size(); ++i) {
    if (!was1[i]) {
      int a, b, c;
      tie(a, b, c) = ey[i];
      ay[a].emplace_back(b, c);
    }
  }
  vector<tuple<int, int, int>> ansx;
  for (int i = 0; i < vx.size(); ++i) {
    for (int j : gx[i]) ax[i].emplace_back(j, j);
    sort((ax[i]).begin(), (ax[i]).end());
    int l = -1;
    int r = -1;
    for (auto p : ax[i]) {
      if (l == -1)
        l = p.first, r = p.second;
      else if (r >= p.first) {
        r = max(r, p.second);
      } else {
        ansx.emplace_back(i, l, r);
        l = p.first, r = p.second;
      }
    }
    if (l != -1) ansx.emplace_back(i, l, r);
  }
  vector<tuple<int, int, int>> ansy;
  for (int i = 0; i < vy.size(); ++i) {
    for (int j : gy[i]) ay[i].emplace_back(j, j);
    sort((ay[i]).begin(), (ay[i]).end());
    int l = -1;
    int r = -1;
    for (auto p : ay[i]) {
      if (l == -1)
        l = p.first, r = p.second;
      else if (r >= p.first) {
        r = max(r, p.second);
      } else {
        ansy.emplace_back(i, l, r);
        l = p.first, r = p.second;
      }
    }
    if (l != -1) ansy.emplace_back(i, l, r);
  }
  cout << ansx.size() << "\n";
  for (auto t : ansx) {
    int a, b, c;
    tie(a, b, c) = t;
    cout << vy[b] << " " << vx[a] << " " << vy[c] << " " << vx[a] << "\n";
  }
  cout << ansy.size() << "\n";
  for (auto t : ansy) {
    int a, b, c;
    tie(a, b, c) = t;
    cout << vy[a] << " " << vx[b] << " " << vy[a] << " " << vx[c] << "\n";
  }
  return 0;
}