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;
long long n, m, T, k, d;
const long long big = 1000000007;
vector<int> match2;
vector<int> match;
vector<bool> seen;
template <class G>
bool find(int j, G &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;
      match[j] = -1;
      return 1;
    }
  return 0;
}
template <class G>
int dfs_matching(G &g, int n, int m) {
  match.assign(m, -1);
  match2.assign(n, -1);
  for (int i = 0; i < (n); ++i) {
    seen.assign(m, false);
    for (auto &j : g[i])
      if (find(j, g)) {
        match[j] = i;
        break;
      }
  }
  for (int c1 = 0; c1 < m; c1++) {
    if (match[c1] != -1) {
      match2[match[c1]] = c1;
    }
  }
  return m - count(match.begin(), match.end(), -1);
}
vector<vector<int> > C(4001, vector<int>());
struct seg {
  long long x1, y1, x2, y2;
};
vector<long long> X;
vector<long long> Y;
vector<long long> ind1;
vector<long long> ind2;
void pseg(seg s) {
  cout << s.x1 << " " << s.y1 << " " << s.x2 << " " << s.y2 << "\n";
  return;
}
bool comp1(long long i, long long j) {
  if (X[i] == X[j]) {
    return Y[i] < Y[j];
  } else {
    return X[i] < X[j];
  }
}
bool comp2(long long i, long long j) {
  if (Y[i] == Y[j]) {
    return X[i] < X[j];
  } else {
    return Y[i] < Y[j];
  }
}
bool taken1[1001] = {0};
bool taken2[1001] = {0};
bool yxok(long long i1, long long i2, long long j1, long long j2) {
  long long a1 = ind2[i1];
  long long a2 = ind2[i2];
  long long b1 = ind1[j1];
  long long b2 = ind1[j2];
  if (Y[a1] != Y[a2]) return 0;
  if (X[b1] != X[b2]) return 1;
  if (X[b1] >= max(X[a1], X[a2]) || X[b1] <= min(X[a1], X[a2])) return 1;
  if (Y[a1] >= max(Y[b1], Y[b2]) || Y[a1] <= min(Y[b1], Y[b2])) return 1;
  return 0;
}
vector<vector<int> > C2(4001, vector<int>());
bool mark1[1001] = {0};
bool mark2[1001] = {0};
bool TT[4001] = {0};
bool vis[4001] = {0};
vector<seg> vseg;
vector<seg> hseg;
void dfs(long long i) {
  TT[i] = 1;
  for (int c1 = 0; c1 < (int)(C2[i]).size(); c1++) {
    long long a = C2[i][c1];
    if (!TT[a]) {
      dfs(a);
    }
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b, c, d, e;
  cin >> n;
  for (int c1 = 0; c1 < n; c1++) {
    cin >> a >> b;
    X.push_back(a);
    Y.push_back(b);
    ind1.push_back(c1);
    ind2.push_back(c1);
  }
  sort(ind1.begin(), ind1.end(), comp1);
  sort(ind2.begin(), ind2.end(), comp2);
  for (int c1 = 0; c1 < n - 1; c1++) {
    for (int c2 = 0; c2 < n - 1; c2++) {
      if (Y[ind2[c1]] != Y[ind2[c1 + 1]] || X[ind1[c2]] != X[ind1[c2 + 1]])
        continue;
      if (!yxok(c1, c1 + 1, c2, c2 + 1)) {
        C[c2].push_back(c1);
      }
    }
  }
  dfs_matching(C, n - 1, n - 1);
  vector<int> start;
  for (int c1 = 0; c1 < n - 1; c1++) {
    if (match2[c1] == -1) {
      start.push_back(c1);
    }
    for (int c2 = 0; c2 < (int)(C[c1]).size(); c2++) {
      a = C[c1][c2];
      if (match2[c1] == a) {
        C2[a + n].push_back(c1);
      } else {
        C2[c1].push_back(a + n);
      }
    }
  }
  for (int c1 = 0; c1 < (int)(start).size(); c1++) {
    dfs(start[c1]);
  }
  for (int c1 = 0; c1 < n - 1; c1++) {
    if (TT[c1]) taken1[c1] = 1;
    if (!TT[n + c1]) taken2[c1] = 1;
  }
  for (int c1 = 0; c1 < n; c1++) {
    a = ind1[c1];
    if (mark1[a]) continue;
    long long x = X[a];
    long long y1 = Y[a];
    long long y2 = Y[a];
    for (int c2 = c1; c2 < n; c2++) {
      b = ind1[c2];
      if (X[b] != x) break;
      if (c2 > c1 && !taken1[c2 - 1]) break;
      mark1[b] = 1;
      y2 = Y[b];
    }
    vseg.push_back({x, y1, x, y2});
  }
  for (int c1 = 0; c1 < n; c1++) {
    a = ind2[c1];
    if (mark2[a]) continue;
    long long y = Y[a];
    long long x1 = X[a];
    long long x2 = X[a];
    for (int c2 = c1; c2 < n; c2++) {
      b = ind2[c2];
      if (Y[b] != y) break;
      if (c2 > c1 && !taken2[c2 - 1]) break;
      mark2[b] = 1;
      x2 = X[b];
    }
    hseg.push_back({x1, y, x2, y});
  }
  cout << (int)(hseg).size() << "\n";
  for (int c1 = 0; c1 < (int)(hseg).size(); c1++) {
    pseg(hseg[c1]);
  }
  cout << (int)(vseg).size() << "\n";
  for (int c1 = 0; c1 < (int)(vseg).size(); c1++) {
    pseg(vseg[c1]);
  }
  return 0;
}