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 maxn = 1010;
struct Section {
  int l, r, pos;
  Section(int _l = 0, int _r = 0, int _pos = 0) : l(_l), r(_r), pos(_pos) {}
  inline bool operator<(const Section& rhs) const {
    if (l != rhs.l) return l < rhs.l;
    if (r != rhs.r) return r < rhs.r;
    return pos < rhs.pos;
  }
};
struct Segment {
  int x, y, x2, y2;
  Segment(int _x = 0, int _y = 0, int _x2 = 0, int _y2 = 0)
      : x(_x), y(_y), x2(_x2), y2(_y2) {}
};
vector<Segment> ans_h, ans_v;
vector<int> xs, ys, vx[maxn], vy[maxn], dx[maxn], dy[maxn];
pair<int, int> pt[maxn];
vector<Section> sec_x, sec_y;
vector<int> g[maxn];
bool vis[maxn];
int x_match[maxn], y_match[maxn];
bool dfs(int u) {
  vis[u] = true;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    if (!y_match[v] || (!vis[y_match[v]] && dfs(y_match[v]))) {
      x_match[u] = v;
      y_match[v] = u;
      return true;
    }
  }
  return false;
}
bool mark_x[maxn], mark_y[maxn];
void dfs_sec(int u) {
  mark_x[u] = false;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    mark_y[v] = true;
    if (y_match[v] && mark_x[y_match[v]]) {
      dfs_sec(y_match[v]);
    }
  }
}
int main() {
  int n, x, y;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x, &y);
    xs.push_back(x);
    ys.push_back(y);
    pt[i] = pair<int, int>(x, y);
  }
  sort(xs.begin(), xs.end());
  xs.erase(unique(xs.begin(), xs.end()), xs.end());
  sort(ys.begin(), ys.end());
  ys.erase(unique(ys.begin(), ys.end()), ys.end());
  for (int i = 1; i <= n; i++) {
    pt[i].first =
        lower_bound(xs.begin(), xs.end(), pt[i].first) - xs.begin() + 1;
    pt[i].second =
        lower_bound(ys.begin(), ys.end(), pt[i].second) - ys.begin() + 1;
    vx[pt[i].first].push_back(pt[i].second);
    vy[pt[i].second].push_back(pt[i].first);
  }
  for (int i = 1; i <= (int)xs.size(); i++) {
    sort(vx[i].begin(), vx[i].end());
    for (int j = 1; j < (int)vx[i].size(); j++)
      sec_x.push_back(Section(vx[i][j - 1], vx[i][j], i));
  }
  for (int i = 1; i <= (int)ys.size(); i++) {
    sort(vy[i].begin(), vy[i].end());
    for (int j = 1; j < (int)vy[i].size(); j++)
      sec_y.push_back(Section(vy[i][j - 1], vy[i][j], i));
  }
  sort(sec_x.begin(), sec_x.end());
  sort(sec_y.begin(), sec_y.end());
  for (int i = 0; i < (int)sec_x.size(); i++) {
    for (int j = 0; j < (int)sec_y.size(); j++) {
      bool found = true;
      if (sec_x[i].r <= sec_y[j].pos || sec_x[i].l >= sec_y[j].pos)
        found = false;
      if (sec_y[j].r <= sec_x[i].pos || sec_y[j].l >= sec_x[i].pos)
        found = false;
      if (found) g[i + 1].push_back(j + 1);
    }
  }
  for (int i = 1; i <= (int)sec_x.size(); i++) {
    memset(vis, 0, sizeof vis);
    dfs(i);
    mark_x[i] = true;
  }
  for (int i = 1; i <= (int)sec_x.size(); i++)
    if (!x_match[i]) dfs_sec(i);
  for (int i = 1; i <= (int)ys.size(); i++)
    if (vy[i].size() >= 1) dy[i].push_back(vy[i][0]);
  for (int i = 1; i <= (int)xs.size(); i++)
    if (vx[i].size() >= 1) dx[i].push_back(vx[i][0]);
  for (int i = 1; i <= (int)sec_y.size(); i++)
    if (mark_y[i]) {
      dy[sec_y[i - 1].pos].push_back(sec_y[i - 1].l);
      dy[sec_y[i - 1].pos].push_back(sec_y[i - 1].r);
    }
  for (int i = 1; i <= (int)sec_x.size(); i++)
    if (mark_x[i]) {
      dx[sec_x[i - 1].pos].push_back(sec_x[i - 1].l);
      dx[sec_x[i - 1].pos].push_back(sec_x[i - 1].r);
    }
  for (int i = 1; i <= (int)ys.size(); i++)
    if (vy[i].size() >= 1) dy[i].push_back(vy[i].back());
  for (int i = 1; i <= (int)xs.size(); i++)
    if (vx[i].size() >= 1) dx[i].push_back(vx[i].back());
  int ans = 0;
  for (int i = 1; i <= (int)ys.size(); i++) ans += dy[i].size();
  printf("%d\n", ans >> 1);
  for (int i = 1; i <= (int)ys.size(); i++)
    for (int j = 0; j < (int)dy[i].size(); j += 2)
      printf("%d %d %d %d\n", xs[dy[i][j] - 1], ys[i - 1], xs[dy[i][j + 1] - 1],
             ys[i - 1]);
  ans = 0;
  for (int i = 1; i <= (int)xs.size(); i++) ans += dx[i].size();
  printf("%d\n", ans >> 1);
  for (int i = 1; i <= (int)xs.size(); i++)
    for (int j = 0; j < (int)dx[i].size(); j += 2)
      printf("%d %d %d %d\n", xs[i - 1], ys[dx[i][j] - 1], xs[i - 1],
             ys[dx[i][j + 1] - 1]);
  return 0;
}