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>
int szx, szy;
using namespace std;
class MatchingGraph {
 public:
  int n, res;
  vector<vector<int> > graph;
  vector<bool> vis;
  bool dfs(int v) {
    vis[v] = true;
    for (int i = 0; i < (int)graph[v].size(); i++) {
      int nx = graph[v][i];
      if (match[nx] == -1 || (!vis[match[nx]] && dfs(match[nx]))) {
        match[v] = nx;
        match[nx] = v;
        return true;
      }
    }
    return false;
  }
  bool matching() {
    for (int i = 0; i < n; i++) vis[i] = false;
    bool changed = false;
    for (int i = 0; i < n; i++)
      if (match[i] == -1 && !vis[i] && dfs(i)) {
        res++;
        changed = true;
      }
    return changed;
  }
  vector<int> match;
  MatchingGraph(int n) : n(n), res(0) {
    vis = vector<bool>(n);
    match = vector<int>(n);
    graph = vector<vector<int> >(n);
    for (int i = 0; i < n; i++) match[i] = -1;
  }
  void add_edge(int u, int v) {
    graph[u].push_back(v);
    graph[v].push_back(u);
  }
  int max_matching() {
    while (matching())
      ;
    return res;
  }
};
int n;
map<int, vector<int> > mx, my;
struct line {
  int sx, sy, ex, ey;
};
vector<line> ansx, ansy;
line joinx[1001], joiny[1001];
bool chx[1001], chy[1001];
bool cant[1001][1001];
bool vis[2001];
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x, y;
    cin >> x >> y;
    mx[x].push_back(y);
    my[y].push_back(x);
  }
  for (auto cur : mx) {
    auto v = cur.second;
    sort(v.begin(), v.end());
    for (int i = 1; i < v.size(); i++) {
      line newi = {cur.first, v[i - 1], cur.first, v[i]};
      szx++;
      joinx[szx] = newi;
    }
  }
  for (auto cur : my) {
    auto v = cur.second;
    sort(v.begin(), v.end());
    for (int i = 1; i < v.size(); i++) {
      line newi = {v[i - 1], cur.first, v[i], cur.first};
      szy++;
      joiny[szy] = newi;
    }
  }
  MatchingGraph g(szx + szy + 1);
  for (int i = 1; i <= szx; i++) {
    for (int j = 1; j <= szy; j++) {
      if (joinx[i].sy < joiny[j].sy && joiny[j].sy < joinx[i].ey &&
          joiny[j].sx < joinx[i].sx && joinx[i].sx < joiny[j].ex) {
        cant[i][j] = true;
        g.add_edge(i, j + szx);
      }
    }
  }
  int lol = g.max_matching();
  queue<int> q;
  for (int i = 1; i <= szx; i++) {
    if (g.match[i] == -1) {
      vis[i] = true;
      q.push(i);
    }
  }
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    if (cur <= szx) {
      for (int i = 1; i <= szy; i++) {
        if (!cant[cur][i] || g.match[i + szx] == cur || vis[i + szx]) continue;
        vis[i + szx] = true;
        q.push(i + szx);
      }
    } else {
      for (int i = 1; i <= szx; i++) {
        if (!cant[i][cur - szx] || g.match[i] != cur || vis[i]) continue;
        vis[i] = true;
        q.push(i);
      }
    }
  }
  for (int i = 1; i <= szx; i++)
    if (vis[i]) chx[i] = true;
  for (int i = 1; i <= szy; i++)
    if (!vis[i + szx]) chy[i] = true;
  int tx = 0, ty = 0;
  for (auto cur : mx) {
    auto v = cur.second;
    sort(v.begin(), v.end());
    line newi = {cur.first, v[0], cur.first, v[0]};
    for (int i = 1; i < v.size(); i++) {
      tx++;
      if (chx[tx]) {
        newi.ey = v[i];
        continue;
      }
      ansx.push_back(newi);
      newi = {cur.first, v[i], cur.first, v[i]};
    }
    ansx.push_back(newi);
  }
  for (auto cur : my) {
    auto v = cur.second;
    sort(v.begin(), v.end());
    line newi = {v[0], cur.first, v[0], cur.first};
    for (int i = 1; i < v.size(); i++) {
      ty++;
      if (chy[ty]) {
        newi.ex = v[i];
        continue;
      }
      ansy.push_back(newi);
      newi = {v[i], cur.first, v[i], cur.first};
    }
    ansy.push_back(newi);
  }
  cout << ansy.size() << endl;
  for (auto cur : ansy) {
    cout << cur.sx << ' ' << cur.sy << ' ' << cur.ex << ' ' << cur.ey << '\n';
  }
  cout << ansx.size() << endl;
  for (auto cur : ansx) {
    cout << cur.sx << ' ' << cur.sy << ' ' << cur.ex << ' ' << cur.ey << '\n';
  }
}