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;
namespace Matching {
const int MX = 40040, MY = 40040;
vector<int> E[MX], RE[MY];
int xy[MX], yx[MY];
int n, m;
void addE(int x, int y) {
  E[x].push_back(y);
  RE[y].push_back(x);
}
void setnm(int sn, int sm) {
  n = sn;
  m = sm;
}
int tdis[MX], que[MX], *dis = tdis + 1;
int bfs() {
  int *fr = que, *re = que;
  for (int i = 1; i <= n; i++) {
    if (xy[i] == -1)
      *fr++ = i, dis[i] = 0;
    else
      dis[i] = -1;
  }
  dis[-1] = -1;
  while (fr != re) {
    int t = *re++;
    if (t == -1) return 1;
    for (int e : E[t]) {
      if (dis[yx[e]] == -1) dis[yx[e]] = dis[t] + 1, *fr++ = yx[e];
    }
  }
  return 0;
}
int dfs(int x) {
  for (int e : E[x]) {
    if (yx[e] == -1 || (dis[yx[e]] == dis[x] + 1 && dfs(yx[e]))) {
      xy[x] = e;
      yx[e] = x;
      return 1;
    }
  }
  dis[x] = -1;
  return 0;
}
void Do(vector<int>& aa, vector<int>& bb) {
  memset(xy, -1, sizeof xy);
  memset(yx, -1, sizeof yx);
  int ans = 0;
  while (bfs()) {
    for (int i = 1; i <= n; i++)
      if (xy[i] == -1 && dfs(i)) ++ans;
  }
  int chka[1010] = {}, chkb[1010] = {};
  vector<int> v;
  for (int i = 1; i <= n; i++)
    if (xy[i] == -1) v.push_back(i), chka[i] = 1;
  for (int i = 0; i < ((int)(v).size()); i++) {
    int t = v[i];
    for (int e : E[t])
      if (yx[e] != -1 && chka[yx[e]] == 0) {
        chka[yx[e]] = 1;
        v.push_back(yx[e]);
      }
  }
  aa = v;
  v.clear();
  for (int i = 1; i <= m; i++)
    if (yx[i] == -1) v.push_back(i), chkb[i] = 1;
  for (int i = 0; i < ((int)(v).size()); i++) {
    int t = v[i];
    for (int e : RE[t])
      if (xy[e] != -1 && chkb[xy[e]] == 0) {
        chkb[xy[e]] = 1;
        v.push_back(xy[e]);
      }
  }
  bb = v;
  v.clear();
  for (int i = 1; i <= n; i++)
    if (xy[i] != -1 && chka[i] == 0 && chkb[xy[i]] == 0) {
      aa.push_back(i);
    }
}
}  // namespace Matching
int n;
pair<int, int> p[1010];
int mark[1010][1010];
int num_x[1010][1010];
int num_y[1010][1010];
int cnt_x, cnt_y;
int chx[100010], chy[100010];
vector<pair<pair<int, int>, pair<int, int> > > ans[2];
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &p[i].first, &p[i].second);
  vector<int> vx, vy;
  for (int i = 1; i <= n; i++)
    vx.push_back(p[i].first), vy.push_back(p[i].second);
  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 = 1; i <= n; i++)
    p[i].first =
        (int)(lower_bound((vx).begin(), (vx).end(), p[i].first) - vx.begin());
  for (int i = 1; i <= n; i++)
    p[i].second =
        (int)(lower_bound((vy).begin(), (vy).end(), p[i].second) - vy.begin());
  for (int i = 1; i <= n; i++) {
    mark[p[i].first][p[i].second] = 1;
  }
  for (int i = 0; i < ((int)(vx).size()); i++) {
    int p = -1;
    for (int j = 0; j < ((int)(vy).size()); j++) {
      if (mark[i][j]) {
        if (p != -1) {
          ++cnt_x;
          for (int a = p + 1; a < j; a++) num_x[i][a] = cnt_x;
        }
        p = j;
      }
    }
  }
  for (int j = 0; j < ((int)(vy).size()); j++) {
    int p = -1;
    for (int i = 0; i < ((int)(vx).size()); i++) {
      if (mark[i][j]) {
        if (p != -1) {
          ++cnt_y;
          for (int a = p + 1; a < i; a++) num_y[a][j] = cnt_y;
        }
        p = i;
      }
    }
  }
  Matching::setnm(cnt_x, cnt_y);
  for (int i = 0; i < ((int)(vx).size()); i++)
    for (int j = 0; j < ((int)(vy).size()); j++) {
      if (num_x[i][j] && num_y[i][j]) {
        int a = num_x[i][j];
        int b = num_y[i][j];
        Matching::addE(a, b);
      }
    }
  vector<int> ax, ay;
  Matching::Do(ax, ay);
  for (int e : ax) chx[e] = 1;
  for (int e : ay) chy[e] = 1;
  for (int i = 0; i < ((int)(vx).size()); i++) {
    int p = -1;
    vector<int> temp(((int)(vy).size()));
    for (int j = 0; j < ((int)(vy).size()); j++) {
      int ok = mark[i][j];
      if (mark[i][j] == 0 && chx[num_x[i][j]]) ok = 1;
      temp[j] = ok;
    }
    for (int j = 0; j < ((int)(vy).size()); j++) {
      if (p == -1 && temp[j]) p = j;
      if (temp[j] && (j == ((int)(vy).size()) - 1 || temp[j + 1] == 0)) {
        ans[0].push_back(make_pair(pair<int, int>(i, p), pair<int, int>(i, j)));
        p = -1;
      }
    }
  }
  for (int i = 0; i < ((int)(vy).size()); i++) {
    int p = -1;
    vector<int> temp(((int)(vx).size()));
    for (int j = 0; j < ((int)(vx).size()); j++) {
      int ok = mark[j][i];
      if (mark[j][i] == 0 && chy[num_y[j][i]]) ok = 1;
      temp[j] = ok;
    }
    for (int j = 0; j < ((int)(vx).size()); j++) {
      if (p == -1 && temp[j]) p = j;
      if (temp[j] && (j == ((int)(vx).size()) - 1 || temp[j + 1] == 0)) {
        ans[1].push_back(make_pair(pair<int, int>(p, i), pair<int, int>(j, i)));
        p = -1;
      }
    }
  }
  for (int u = 0; u < 2; u++) {
    printf("%d\n", ((int)(ans[u ^ 1]).size()));
    for (auto e : ans[u ^ 1]) {
      pair<int, int> t = e.first;
      printf("%d %d ", vx[t.first], vy[t.second]);
      t = e.second;
      printf("%d %d\n", vx[t.first], vy[t.second]);
    }
  }
  return 0;
}