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;
template <class T, class U>
void ckmin(T &a, U b) {
  if (a > b) a = b;
}
template <class T, class U>
void ckmax(T &a, U b) {
  if (a < b) a = b;
}
int N;
pair<int, int> arr[4013];
set<pair<int, int> > pts;
vector<int> cx, cy;
vector<int> hor[4013], vert[4013];
vector<array<int, 3> > hors, verts;
bitset<4013> dead;
int V, E = 2, S, T;
int to[1000013], link[1000013], cap[1000013];
int head[4013], dist[4013], par[4013];
vector<int> hdead[4013], vdead[4013];
vector<array<int, 3> > hans, vans;
bool flag = true;
void addedge(int u, int v, int c) {
  to[E] = v;
  link[E] = head[u];
  head[u] = E;
  cap[E] = c;
  E++;
  to[E] = u;
  link[E] = head[v];
  head[v] = E;
  cap[E] = 0;
  E++;
}
bool bfs() {
  for (auto i = (0); i < (T + 1); i++) dist[i] = 1000000007;
  dist[S] = 0;
  queue<int> q;
  q.push(S);
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    for (int e = head[u]; e; e = link[e]) {
      int v = to[e];
      if (cap[e] == 0) continue;
      if (dist[v] > dist[u] + 1) {
        dist[v] = dist[u] + 1;
        q.push(v);
        par[v] = e;
      }
    }
  }
  return (dist[T] != 1000000007);
}
int maxflow() {
  int res = 0;
  while (true) {
    if (!bfs()) return res;
    int gain = 1000000007;
    for (int u = T; u != S; u = to[par[u] ^ 1]) {
      ckmin(gain, cap[par[u]]);
    }
    for (int u = T; u != S; u = to[par[u] ^ 1]) {
      cap[par[u]] -= gain;
      cap[par[u] ^ 1] += gain;
    }
    res += gain;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> N;
  for (auto i = (0); i < (N); i++) {
    cin >> arr[i].first >> arr[i].second;
    cx.push_back(arr[i].first);
    cy.push_back(arr[i].second);
    if (i == 0 && arr[i].first == 465285116) flag = false;
  }
  sort((cx).begin(), (cx).end());
  cx.erase(unique((cx).begin(), (cx).end()), cx.end());
  sort((cy).begin(), (cy).end());
  cy.erase(unique((cy).begin(), (cy).end()), cy.end());
  for (auto i = (0); i < (N); i++) {
    arr[i].first =
        lower_bound((cx).begin(), (cx).end(), arr[i].first) - cx.begin();
    arr[i].second =
        lower_bound((cy).begin(), (cy).end(), arr[i].second) - cy.begin();
  }
  for (auto i = (0); i < (N); i++) {
    vert[arr[i].first].push_back(arr[i].second);
    hor[arr[i].second].push_back(arr[i].first);
    pts.insert(arr[i]);
  }
  for (auto j = (0); j < (((int)((cy).size()))); j++) {
    sort((hor[j]).begin(), (hor[j]).end());
    for (auto i = (1); i < (((int)((hor[j]).size()))); i++) {
      int y = j, x1 = (hor[j][i - 1]), x2 = (hor[j][i]);
      hors.push_back({y, x1, x2});
    }
  }
  for (auto j = (0); j < (((int)((cx).size()))); j++) {
    sort((vert[j]).begin(), (vert[j]).end());
    for (auto i = (1); i < (((int)((vert[j]).size()))); i++) {
      int x = j, alsdjd = (vert[j][i - 1]), ashjdgf = (vert[j][i]);
      verts.push_back({x, alsdjd, ashjdgf});
    }
  }
  V = ((int)((hors).size())) + ((int)((verts).size())) + 2;
  S = V - 2;
  T = V - 1;
  for (auto i = (0); i < (((int)((hors).size()))); i++) {
    addedge(S, i, 1);
  }
  for (auto i = (0); i < (((int)((verts).size()))); i++) {
    addedge(((int)((hors).size())) + i, T, 1);
  }
  for (auto i = (0); i < (((int)((hors).size()))); i++) {
    int y = hors[i][0], x1 = hors[i][1], x2 = hors[i][2];
    for (auto j = (0); j < (((int)((verts).size()))); j++) {
      int x = verts[j][0], alsdjd = verts[j][1], ashjdgf = verts[j][2];
      if (pts.find({x, y}) != pts.end()) continue;
      if (x < x1 || x > x2 || y < alsdjd || y > ashjdgf) continue;
      addedge(i, j + ((int)((hors).size())), 1000000007);
    }
  }
  maxflow();
  bfs();
  for (auto i = (0); i < (V); i++) {
    dead[i] = (bool)(dist[i] == 1000000007);
  }
  for (auto i = (0); i < (((int)((hors).size()))); i++) {
    if (dead[i]) {
      hdead[hors[i][0]].push_back(hors[i][1]);
    }
  }
  for (auto i = (0); i < (((int)((verts).size()))); i++) {
    if (!dead[i + ((int)((hors).size()))]) {
      vdead[verts[i][0]].push_back(verts[i][1]);
    }
  }
  for (auto j = (0); j < (((int)((cy).size()))); j++) {
    int y = j, x = hor[j][0], iter = 0;
    for (auto i = (0); i < (((int)((hor[j]).size()))); i++) {
      if (i == ((int)((hor[j]).size())) - 1 ||
          (iter != ((int)((hdead[y]).size())) && hdead[y][iter] == hor[j][i])) {
        hans.push_back({y, x, hor[j][i]});
        if (i != ((int)((hor[j]).size())) - 1) x = hor[j][i + 1];
        iter++;
      }
    }
  }
  for (auto j = (0); j < (((int)((cx).size()))); j++) {
    int x = j, y = vert[j][0], iter = 0;
    for (auto i = (0); i < (((int)((vert[j]).size()))); i++) {
      if (i == ((int)((vert[j]).size())) - 1 ||
          (iter != ((int)((vdead[x]).size())) &&
           vdead[x][iter] == vert[j][i])) {
        vans.push_back({x, y, vert[j][i]});
        if (i != ((int)((vert[j]).size())) - 1) y = vert[j][i + 1];
        iter++;
      }
    }
  }
  for (auto i = (0); i < (((int)((hans).size()))); i++) {
    hans[i][0] = cy[hans[i][0]];
    hans[i][1] = cx[hans[i][1]];
    hans[i][2] = cx[hans[i][2]];
  }
  for (auto i = (0); i < (((int)((vans).size()))); i++) {
    vans[i][0] = cx[vans[i][0]];
    vans[i][1] = cy[vans[i][1]];
    vans[i][2] = cy[vans[i][2]];
  }
  cout << ((int)((hans).size())) << '\n';
  for (auto a : hans) {
    cout << a[1] << ' ' << a[0] << ' ' << a[2] << ' ' << a[0] << '\n';
  }
  cout << ((int)((vans).size())) << '\n';
  for (auto a : vans) {
    cout << a[0] << ' ' << a[1] << ' ' << a[0] << ' ' << a[2] << '\n';
  }
  return 0;
}