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 inf = 0x3f3f3f3f;
const int inf_ = 0x7fffffff;
const long long inff = 4557430888798830399ll;
const double pi = acos(-1.0);
long long mod = 1e9 + 7;
struct HUNGARY {
  HUNGARY() { init(0, 0); };
  int n, m, to[10004], vt[10004];
  bool vis[10004];
  vector<int> N[10004];
  void init(int _n, int _m) {
    n = _n;
    m = _m;
    for (int i = (1); i <= (n); ++i) N[i].clear();
    memset(to, 0, sizeof(to));
    memset(vt, 0, sizeof(vt));
  }
  void link(int u, int v) { N[u].push_back(v); }
  bool dfs(int u) {
    for (auto v : N[u])
      if (!vis[v]) {
        vis[v] = 1;
        if (!to[v] || dfs(to[v])) {
          to[v] = u, vt[u] = v;
          return 1;
        }
      }
    return 0;
  }
  void run() {
    for (int i = (1); i <= (n); ++i)
      if (!vt[i]) {
        memset(vis, 0, sizeof(vis));
        dfs(i);
      }
  }
  set<int> A, B;
  void dfsc(int u) {
    A.erase(u);
    for (auto v : N[u])
      if (!vis[v]) {
        vis[v] = 1;
        B.insert(v);
        if (to[v] && A.count(to[v])) dfsc(to[v]);
      }
  }
  void cover() {
    memset(vis, 0, sizeof(vis));
    A.clear();
    B.clear();
    for (int i = (1); i <= (n); ++i) A.insert(i);
    for (int i = (1); i <= (n); ++i)
      if (!vt[i]) dfsc(i);
  }
} h;
map<int, vector<int> > X, Y;
vector<pair<pair<int, int>, pair<int, int> > > V, H, A, B;
void pt(pair<int, int> p) { cout << "(" << p.first << "," << p.second << ")"; }
bool cross(pair<pair<int, int>, pair<int, int> > p,
           pair<pair<int, int>, pair<int, int> > q) {
  return q.first.first < p.first.first && p.first.first < q.second.first &&
         p.first.second < q.second.second && q.second.second < p.second.second;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, x, y;
  vector<pair<int, int> > z;
  int o[10004];
  cin >> n;
  for (int i = (0); i < (n); ++i) {
    cin >> x >> y;
    X[x].push_back(y);
    Y[y].push_back(x);
    z.push_back(make_pair(x, y));
  }
  for (auto z : X) {
    sort((z.second).begin(), (z.second).end());
    for (int i = (0); i < (((int)z.second.size()) - 1); ++i)
      V.push_back(make_pair(make_pair(z.first, z.second[i]),
                            make_pair(z.first, z.second[i + 1])));
  }
  for (auto z : Y) {
    sort((z.second).begin(), (z.second).end());
    for (int i = (0); i < (((int)z.second.size()) - 1); ++i)
      H.push_back(make_pair(make_pair(z.second[i], z.first),
                            make_pair(z.second[i + 1], z.first)));
  }
  h.init(((int)V.size()), ((int)H.size()));
  for (int i = (0); i < (((int)V.size())); ++i)
    for (int j = (0); j < (((int)H.size())); ++j)
      if (cross(V[i], H[j])) h.link(i + 1, j + 1);
  h.run();
  h.cover();
  for (int i = (0); i < (((int)V.size())); ++i)
    if (!h.A.count(i + 1)) {
      if (!((int)A.size()) || A.back().second != V[i].first)
        A.push_back(V[i]);
      else
        A[((int)A.size()) - 1].second = V[i].second;
    }
  for (int i = (0); i < (((int)H.size())); ++i)
    if (!h.B.count(i + 1)) {
      if (!((int)B.size()) || B.back().second != H[i].first)
        B.push_back(H[i]);
      else
        B[((int)B.size()) - 1].second = H[i].second;
    }
  memset(o, 0, sizeof(o));
  for (int i = (0); i < (((int)z.size())); ++i) {
    for (int j = (0); j < (((int)A.size())); ++j)
      if (A[j].first.first == z[i].first && A[j].first.second <= z[i].second &&
          z[i].second <= A[j].second.second)
        o[i] |= 1;
    for (int j = (0); j < (((int)B.size())); ++j)
      if (B[j].second.second == z[i].second && B[j].first.first <= z[i].first &&
          z[i].first <= B[j].second.first)
        o[i] |= 2;
  }
  for (int i = (0); i < (((int)z.size())); ++i) {
    if ((o[i] & 1) == 0) A.push_back(make_pair(z[i], z[i]));
    if ((o[i] & 2) == 0) B.push_back(make_pair(z[i], z[i]));
  }
  swap(A, B);
  cout << ((int)A.size()) << endl;
  for (auto z : A)
    cout << z.first.first << " " << z.first.second << " " << z.second.first
         << " " << z.second.second << endl;
  cout << ((int)B.size()) << endl;
  for (auto z : B)
    cout << z.first.first << " " << z.first.second << " " << z.second.first
         << " " << z.second.second << endl;
}