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 maxn = 2000 + 5;
const int inf = 1e9 + 1;
int x[maxn], y[maxn];
int match[maxn];
bool ux[maxn], uy[maxn], vs[maxn], hv[maxn];
vector<int> kx[maxn], ky[maxn];
vector<int> g[maxn], r[maxn];
set<pair<int, int>> cx[maxn], cy[maxn];
pair<int, int> inter(tuple<int, int, int> sx, tuple<int, int, int> sy) {
  if (get<1>(sx) >= get<0>(sy) || get<2>(sx) <= get<0>(sy))
    return make_pair(inf, inf);
  if (get<1>(sy) >= get<0>(sx) || get<2>(sy) <= get<0>(sx))
    return make_pair(inf, inf);
  return make_pair(get<0>(sx), get<0>(sy));
}
bool dfs(int x) {
  ux[x] = true;
  for (const int &y : g[x]) {
    if (uy[y]) continue;
    uy[y] = true;
    if (match[y] == -1 || dfs(match[y])) {
      match[y] = x;
      return true;
    }
  }
  return false;
}
void dfs2(int x) {
  vs[x] = true;
  for (const int &u : r[x]) {
    if (vs[u]) continue;
    dfs2(u);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  vector<int> vx, vy;
  for (int i = 0; i < n; ++i) {
    scanf("%d%d", &x[i], &y[i]);
    vx.push_back(x[i]);
    vy.push_back(y[i]);
  }
  sort(vx.begin(), vx.end());
  sort(vy.begin(), vy.end());
  vx.resize(unique(vx.begin(), vx.end()) - vx.begin());
  vy.resize(unique(vy.begin(), vy.end()) - vy.begin());
  for (int i = 0; i < n; ++i) {
    x[i] = lower_bound(vx.begin(), vx.end(), x[i]) - vx.begin();
    y[i] = lower_bound(vy.begin(), vy.end(), y[i]) - vy.begin();
    kx[x[i]].push_back(i);
    ky[y[i]].push_back(i);
  }
  vector<tuple<int, int, int>> sx, sy;
  for (int i = 0; i < (int)vx.size(); ++i) {
    sort(kx[i].begin(), kx[i].end(), [&](int i, int j) { return y[i] < y[j]; });
    for (int j = 1; j < (int)kx[i].size(); ++j)
      sx.emplace_back(i, y[kx[i][j - 1]], y[kx[i][j]]);
  }
  for (int i = 0; i < (int)vy.size(); ++i) {
    sort(ky[i].begin(), ky[i].end(), [&](int i, int j) { return x[i] < x[j]; });
    for (int j = 1; j < (int)ky[i].size(); ++j)
      sy.emplace_back(i, x[ky[i][j - 1]], x[ky[i][j]]);
  }
  for (int i = 0; i < (int)sx.size(); ++i) {
    for (int j = 0; j < (int)sy.size(); ++j) {
      int x, y;
      tie(x, y) = inter(sx[i], sy[j]);
      if (x == inf) continue;
      g[i].push_back(j);
    }
  }
  memset(match, -1, sizeof(match));
  for (int i = 0; i < (int)sx.size(); ++i) {
    memset(uy, false, sizeof(uy));
    dfs(i);
  }
  for (int i = 0; i < (int)sy.size(); ++i) {
    if (~match[i]) hv[match[i]] = true;
  }
  for (int i = 0; i < (int)sx.size(); ++i) {
    for (const int &y : g[i]) {
      if (match[y] == i)
        r[y + sx.size()].push_back(i);
      else
        r[i].push_back(y + sx.size());
    }
  }
  for (int i = 0; i < (int)sx.size(); ++i) {
    if (hv[i]) continue;
    dfs2(i);
  }
  for (int i = 0; i < (int)sx.size(); ++i) {
    if (!vs[i]) {
      int x = get<0>(sx[i]);
      cx[x].insert(make_pair(get<1>(sx[i]), get<2>(sx[i])));
    }
  }
  for (int i = 0; i < (int)sy.size(); ++i) {
    if (vs[i + sx.size()]) {
      int y = get<0>(sy[i]);
      cy[y].insert(make_pair(get<1>(sy[i]), get<2>(sy[i])));
    }
  }
  vector<tuple<int, int, int>> ax, ay;
  for (int i = 0; i < (int)vx.size(); ++i) {
    for (int j = 0; j < (int)kx[i].size();) {
      int k = j + 1;
      while (k < (int)kx[i].size() &&
             cx[i].count(make_pair(y[kx[i][k - 1]], y[kx[i][k]])) == 0)
        ++k;
      ax.emplace_back(i, y[kx[i][j]], y[kx[i][k - 1]]);
      j = k;
    }
  }
  for (int i = 0; i < (int)vy.size(); ++i) {
    for (int j = 0; j < (int)ky[i].size();) {
      int k = j + 1;
      while (k < (int)ky[i].size() &&
             cy[i].count(make_pair(x[ky[i][k - 1]], x[ky[i][k]])) == 0)
        ++k;
      ay.emplace_back(i, x[ky[i][j]], x[ky[i][k - 1]]);
      j = k;
    }
  }
  printf("%d\n", (int)ay.size());
  for (int i = 0; i < (int)ay.size(); ++i) {
    int y, l, r;
    tie(y, l, r) = ay[i];
    printf("%d %d %d %d\n", vx[l], vy[y], vx[r], vy[y]);
  }
  printf("%d\n", (int)ax.size());
  for (int i = 0; i < (int)ax.size(); ++i) {
    int x, l, r;
    tie(x, l, r) = ax[i];
    printf("%d %d %d %d\n", vx[x], vy[l], vx[x], vy[r]);
  }
  return 0;
}