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 = 1e3 + 10;
int n;
int a[N][2];
int ans[2][N];
int py[N], px[N];
struct {
  int n1, n2;
  int match[2][N];
  int h[2][N];
  vector<int> v[N];
  void add_edge(int x, int y) { v[x].push_back(y); }
  bool DFS(int x) {
    h[0][x] = 1;
    for (auto y : v[x]) {
      if (h[1][y] == 1) continue;
      if (y == match[0][x]) continue;
      h[1][y] = 1;
      if ((match[1][y] == -1) || DFS(match[1][y])) {
        match[0][x] = y;
        match[1][y] = x;
        return 1;
      }
    }
    return 0;
  }
  int q[N];
  int get() {
    int top = 1, bot = n1;
    for (int i = 1; i <= n1; i++) {
      q[i] = i;
    }
    memset(match, -1, sizeof(match));
    while (1) {
      memset(h, 0, sizeof(h));
      bool okay = 0;
      for (int i = top; i <= bot; i++) {
        if (DFS(q[i])) {
          okay = 1;
          swap(q[i--], q[bot--]);
        }
      }
      if (!okay) break;
    }
    for (int i = 1; i <= n2; i++) {
      ans[1][i] = (match[1][i] != -1 && h[1][i]);
    }
    for (int i = 1; i <= n1; i++) {
      ans[0][i] = (match[0][i] != -1 && !ans[1][match[0][i]]);
    }
    return bot;
  }
} match;
struct line {
  int x, L, R;
  line(int x, int L, int R) : x(x), L(L), R(R) {}
};
vector<line> xline, yline;
bool cross(line a, line b) {
  return (b.L <= a.x && b.R >= a.x && a.L <= b.x && a.R >= b.x);
}
set<pair<int, int>> mset;
void prepare() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i][0] >> a[i][1];
  for (int i = 1; i <= n; i++) mset.insert(make_pair(a[i][0], a[i][1]));
  for (int i = 1; i <= n; i++) px[i] = i;
  sort(px + 1, px + n + 1, [](int x, int y) {
    if (a[x][0] == a[y][0]) return a[x][1] < a[y][1];
    return a[x][0] < a[y][0];
  });
  for (int i = 1; i <= n; i++) py[i] = i;
  sort(py + 1, py + n + 1, [](int x, int y) {
    if (a[x][1] == a[y][1]) return a[x][0] < a[y][0];
    return a[x][1] < a[y][1];
  });
  for (int i = 1; i < n; i++)
    if (a[px[i]][0] == a[px[i + 1]][0]) {
      int L = a[px[i]][1], R = a[px[i + 1]][1];
      xline.push_back(line(a[px[i]][0], L, R));
    }
  for (int i = 1; i < n; i++)
    if (a[py[i]][1] == a[py[i + 1]][1]) {
      int L = a[py[i]][0], R = a[py[i + 1]][0];
      yline.push_back(line(a[py[i]][1], L, R));
    }
  match.n1 = xline.size();
  match.n2 = yline.size();
  for (int i = 0; i < xline.size(); i++)
    for (int j = 0; j < yline.size(); j++)
      if (cross(xline[i], yline[j])) {
        if (!mset.count(make_pair(xline[i].x, yline[j].x)))
          match.add_edge(i + 1, j + 1);
      }
}
int rans[N];
void solveX() {
  memset(rans, 0, sizeof(rans));
  for (int en = 0; en < xline.size(); en++)
    if (!ans[0][en + 1]) {
      int xa = xline[en].x, ya = xline[en].L;
      int L = 1, R = n;
      while (L <= R) {
        int mid = (L + R) / 2;
        bool okay =
            (xa != a[px[mid]][0]) ? xa < a[px[mid]][0] : ya < a[px[mid]][1];
        if (okay)
          R = mid - 1;
        else
          L = mid + 1;
      }
      rans[R] = 1;
    }
  vector<line> xans;
  for (int en = 1; en <= n; en++) {
    int st = en;
    while (rans[en]) en++;
    xans.push_back(line(a[px[st]][0], a[px[st]][1], a[px[en]][1]));
  }
  cout << xans.size() << '\n';
  for (auto i : xans)
    cout << i.x << " " << i.L << " " << i.x << " " << i.R << '\n';
}
void solveY() {
  memset(rans, 0, sizeof(rans));
  for (int en = 0; en < yline.size(); en++)
    if (!ans[1][en + 1]) {
      int xa = yline[en].L, ya = yline[en].x;
      int L = 1, R = n;
      while (L <= R) {
        int mid = (L + R) / 2;
        bool okay =
            (ya != a[py[mid]][1]) ? ya < a[py[mid]][1] : xa < a[py[mid]][0];
        if (okay)
          R = mid - 1;
        else
          L = mid + 1;
      }
      rans[R] = 1;
    }
  vector<line> yans;
  for (int en = 1; en <= n; en++) {
    int st = en;
    while (rans[en]) en++;
    yans.push_back(line(a[py[st]][1], a[py[st]][0], a[py[en]][0]));
  }
  cout << yans.size() << '\n';
  for (auto i : yans)
    cout << i.L << " " << i.x << " " << i.R << " " << i.x << '\n';
}
void solve() {
  match.get();
  solveY();
  solveX();
}
int main() {
  prepare();
  solve();
}