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 N = 1000 + 5;
const int M = 2055;
int n;
pair<int, int> a[N];
int rg[N], dw[N];
int pmap[N][N], p1[N][N], p2[N][N];
vector<int> M1[N], M2[N];
bool intersect(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) {
  return (y1 <= y3 and y3 <= y2) and (x3 <= x1 and x1 <= x4) and !pmap[x1][y3];
}
const int maxn = (int)1e6 + 11111;
struct edge {
  int v, u, f, c;
  edge() {}
  edge(int v, int u, int f, int c) : v(v), u(u), f(f), c(c) {}
};
edge mas[maxn];
int posit = 0;
vector<int> ed[M];
void add_edge(int v, int u) {
  mas[posit] = edge(v, u, 0, 1);
  ed[v].push_back(posit++);
  mas[posit] = edge(u, v, 0, 0);
  ed[u].push_back(posit++);
}
int d[M];
int iter[M];
int num = 2;
const int inf = (int)1e9;
bool bfs(int s, int t) {
  for (int i = 0; i < num; i++) {
    d[i] = inf;
    iter[i] = 0;
  }
  d[s] = 0;
  queue<int> q;
  q.push(s);
  while (!q.empty()) {
    int v = q.front();
    q.pop();
    for (int i = 0; i < (int)ed[v].size(); i++) {
      int it = ed[v][i];
      int u = mas[it].u;
      if (mas[it].f != mas[it].c && d[u] == inf) {
        d[u] = d[v] + 1;
        q.push(u);
      }
    }
  }
  return d[t] != inf;
}
int dfs(int s, int t, int c) {
  if (s == t) {
    return c;
  }
  int w = 0;
  while (iter[s] != (int)ed[s].size()) {
    int it = ed[s][iter[s]];
    int u = mas[it].u;
    if (d[u] == d[s] + 1) {
      int cnt = dfs(u, t, min(c, mas[it].c - mas[it].f));
      mas[it].f += cnt;
      mas[it ^ 1].f -= cnt;
      w += cnt;
      c -= cnt;
      if (c == 0) {
        break;
      }
    }
    iter[s]++;
  }
  return w;
}
bool used[M];
void go(int v) {
  used[v] = true;
  for (int i = 0; i < (int)ed[v].size(); i++) {
    int it = ed[v][i];
    int u = mas[it].u;
    if (mas[it].c != mas[it].f && !used[u]) {
      go(u);
    }
  }
}
int main() {
  scanf("%d", &n);
  vector<int> vx, vy;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
    vx.push_back(a[i].first);
    vy.push_back(a[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++) {
    a[i].first = lower_bound(vx.begin(), vx.end(), a[i].first) - vx.begin() + 1;
    a[i].second =
        lower_bound(vy.begin(), vy.end(), a[i].second) - vy.begin() + 1;
  }
  for (int i = 1; i <= n; i++) pmap[a[i].first][a[i].second] = i;
  for (int i = 1; i <= n; i++) {
    M1[a[i].first].push_back(a[i].second);
    M2[a[i].second].push_back(a[i].first);
  }
  for (int i = 1; i <= n; i++) {
    sort(M1[i].begin(), M1[i].end());
    sort(M2[i].begin(), M2[i].end());
  }
  for (int i = 1; i <= n; i++) {
    int id;
    int x, y;
    tie(x, y) = a[i];
    id = lower_bound(M1[x].begin(), M1[x].end(), y + 1) - M1[x].begin();
    rg[i] = (id == M1[x].size() ? -1 : M1[x][id]);
    id = lower_bound(M2[y].begin(), M2[y].end(), x + 1) - M2[y].begin();
    dw[i] = (id == M2[y].size() ? -1 : M2[y][id]);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      if (rg[i] != -1 and dw[j] != -1 and
          intersect(a[i].first, a[i].second, a[i].first, rg[i], a[j].first,
                    a[j].second, dw[j], a[j].second)) {
        add_edge(i * 2 - 1, j * 2);
      }
      if (dw[i] != -1 and rg[j] != -1 and
          intersect(a[j].first, a[j].second, a[j].first, rg[j], a[i].first,
                    a[i].second, dw[i], a[i].second)) {
        add_edge(j * 2 - 1, i * 2);
      }
    }
  }
  int ss = M - 1;
  int tt = M - 2;
  num = M;
  for (int i = 1; i <= n; i++) {
    if (rg[i] != -1) add_edge(ss, i * 2 - 1);
    if (dw[i] != -1) add_edge(i * 2, tt);
  }
  while (bfs(ss, tt)) {
    dfs(ss, tt, inf);
  }
  go(ss);
  vector<int> ai, bi;
  for (int i = 1; i <= n; i++) {
    if (used[2 * i - 1] and rg[i] != -1) {
      ai.push_back(i);
    }
    if (!used[2 * i] and dw[i] != -1) {
      bi.push_back(i);
    }
  }
  for (auto x : ai) p1[a[x].first][a[x].second] = 1;
  for (auto x : bi) p2[a[x].first][a[x].second] = 1;
  vector<pair<pair<int, int>, pair<int, int>>> ans;
  for (int i = 1; i <= n; i++) {
    if (!M2[i].empty()) {
      for (int j = 0; j < M2[i].size(); j++) {
        int k = j;
        while (k < M2[i].size() and p2[M2[i][k]][i]) {
          k++;
        }
        ans.push_back({{M2[i][j], i}, {M2[i][k], i}});
        j = k;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto l : ans)
    printf("%d %d %d %d\n", vx[l.first.first - 1], vy[l.first.second - 1],
           vx[l.second.first - 1], vy[l.second.second - 1]);
  ans.clear();
  for (int i = 1; i <= n; i++) {
    if (!M1[i].empty()) {
      for (int j = 0; j < M1[i].size(); j++) {
        int k = j;
        while (k < M1[i].size() and p1[i][M1[i][k]]) {
          k++;
        }
        ans.push_back({{i, M1[i][j]}, {i, M1[i][k]}});
        j = k;
      }
    }
  }
  printf("%d\n", (int)ans.size());
  for (auto l : ans)
    printf("%d %d %d %d\n", vx[l.first.first - 1], vy[l.first.second - 1],
           vx[l.second.first - 1], vy[l.second.second - 1]);
  return 0;
}