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 MX = 1000;
namespace bipartite_matching {
const int LEFT = MX * MX, RIGHT = MX * MX;
vector<int> G[LEFT];
int paired[LEFT], parent[RIGHT];
bool used[LEFT], coverL[LEFT], coverR[RIGHT];
bool dfs(int v) {
  if (used[v]) return false;
  used[v] = true;
  coverL[v] = false;
  for (int u : G[v]) {
    if (parent[u] == -1 || dfs(parent[u])) {
      paired[v] = u;
      parent[u] = v;
      return true;
    }
    coverR[u] = true;
  }
  return false;
}
int find(int left, int right) {
  memset(paired, -1, sizeof(int) * left);
  memset(parent, -1, sizeof(int) * right);
  bool run = true;
  int size = 0;
  while (run) {
    memset(used, 0, sizeof(bool) * left);
    run = false;
    for (int i = 0; i < left; i++)
      if (paired[i] == -1 && dfs(i)) {
        size++;
        run = true;
      }
  }
  return size;
}
void cover(int left, int right) {
  find(left, right);
  fill(coverL, coverL + left, true);
  memset(coverR, 0, sizeof coverR);
  memset(used, 0, sizeof(bool) * left);
  for (int i = 0; i < left; i++)
    if (paired[i] == -1) dfs(i);
}
}  // namespace bipartite_matching
int x[MX], y[MX];
int main() {
  int n;
  ignore = scanf("%d", &n);
  map<int, vector<int>> row, col;
  set<int> xs, ys;
  for (int i = 0; i < n; i++) {
    ignore = scanf("%d %d", x + i, y + i);
    row[x[i]].push_back(y[i]);
    col[y[i]].push_back(x[i]);
    xs.insert(x[i]);
    ys.insert(y[i]);
  }
  map<pair<int, int>, int> id[2];
  auto getId = [&id](int f, int x, int y) {
    auto p = make_pair(x, y);
    if (id[f].count(p) == 0) {
      int v = id[f].size();
      id[f][p] = v;
    }
    return id[f][p];
  };
  for (auto& p : col) sort(p.second.begin(), p.second.end());
  for (int x : xs) {
    auto& vec = row[x];
    sort(vec.begin(), vec.end());
    size_t i = 0;
    for (int y : ys) {
      if (y <= vec[i]) continue;
      if (i + 1 == vec.size()) break;
      if (y == vec[i + 1]) {
        i++;
        continue;
      }
      if (x < col[y][0] || x > col[y].back()) continue;
      int xx = *prev(lower_bound(col[y].begin(), col[y].end(), x));
      int h = getId(0, x, vec[i]);
      int v = getId(1, y, xx);
      bipartite_matching::G[h].push_back(v);
    }
  }
  bipartite_matching::cover(id[0].size(), id[1].size());
  vector<tuple<int, int, int, int>> h, v;
  for (int x : xs) {
    auto& vec = row[x];
    int prev = -1;
    for (int y : vec) {
      if (bipartite_matching::coverL[getId(0, x, y)]) {
        if (prev == -1) prev = y;
        v.emplace_back(x, prev, x, y);
        prev = -1;
        continue;
      }
      if (prev == -1) prev = y;
    }
    if (prev != -1) v.emplace_back(x, prev, x, vec.back());
  }
  for (int y : ys) {
    auto& vec = col[y];
    int prev = -1;
    for (int x : vec) {
      if (bipartite_matching::coverR[getId(1, y, x)]) {
        if (prev == -1) prev = x;
        h.emplace_back(prev, y, x, y);
        prev = -1;
        continue;
      }
      if (prev == -1) prev = x;
    }
    if (prev != -1) h.emplace_back(prev, y, vec.back(), y);
  }
  printf("%d\n", (int)h.size());
  for (auto& p : h) {
    int a, b, c, d;
    tie(a, b, c, d) = p;
    printf("%d %d %d %d\n", a, b, c, d);
  }
  printf("%d\n", (int)v.size());
  for (auto& p : v) {
    int a, b, c, d;
    tie(a, b, c, d) = p;
    printf("%d %d %d %d\n", a, b, c, d);
  }
  return 0;
}