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 long long mod = 1000000007;
long long powmod(long long a, long long b) {
  long long res = 1;
  a %= mod;
  assert(b >= 0);
  for (; b; b >>= 1) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
const int inf = 0x20202020;
namespace flow {
const int M = 3000000, N = 3000;
int y[M], nxt[M], gap[N], fst[N], c[N], pre[N], q[N], dis[N], vis[N];
int f[M];
int S, T, tot, Tn;
void init(int s, int t, int tn) {
  tot = 1;
  assert(tn < N);
  for (int i = 0; i < tn; i++) fst[i] = 0;
  S = s;
  T = t;
  Tn = tn;
}
void add(int u, int v, int c1, int c2 = 0) {
  tot++;
  y[tot] = v;
  f[tot] = c1;
  nxt[tot] = fst[u];
  fst[u] = tot;
  tot++;
  y[tot] = u;
  f[tot] = c2;
  nxt[tot] = fst[v];
  fst[v] = tot;
}
int sap() {
  int u = S, t = 1;
  int flow = 0;
  for (int i = 0; i < Tn; i++) c[i] = fst[i], dis[i] = Tn, gap[i] = 0;
  q[0] = T;
  dis[T] = 0;
  pre[S] = 0;
  for (int i = 0; i < t; i++) {
    int u = q[i];
    for (int j = fst[u]; j; j = nxt[j])
      if (dis[y[j]] > dis[u] + 1 && f[j ^ 1])
        q[t++] = y[j], dis[y[j]] = dis[u] + 1;
  }
  for (int i = 0; i < Tn; i++) gap[dis[i]]++;
  while (dis[S] <= Tn) {
    while (c[u] && (!f[c[u]] || dis[y[c[u]]] + 1 != dis[u])) c[u] = nxt[c[u]];
    if (c[u]) {
      pre[y[c[u]]] = c[u] ^ 1;
      u = y[c[u]];
      if (u == T) {
        int minf = inf;
        for (int p = pre[T]; p; p = pre[y[p]]) minf = min(minf, f[p ^ 1]);
        for (int p = pre[T]; p; p = pre[y[p]]) f[p ^ 1] -= minf, f[p] += minf;
        flow += minf;
        u = S;
      }
    } else {
      if (!(--gap[dis[u]])) break;
      int mind = Tn;
      c[u] = fst[u];
      for (int j = fst[u]; j; j = nxt[j])
        if (f[j] && dis[y[j]] < mind) mind = dis[y[j]], c[u] = j;
      dis[u] = mind + 1;
      gap[dis[u]]++;
      if (u != S) u = y[pre[u]];
    }
  }
  t = 0;
  q[t++] = S;
  vis[S] = 1;
  for (int i = 0; i < t; i++) {
    int u = q[i];
    for (int j = fst[u]; j; j = nxt[j])
      if (f[j] && !vis[y[j]]) {
        q[t++] = y[j];
        vis[y[j]] = 1;
      }
  }
  return flow;
}
};  // namespace flow
const int N = 2100;
int n, x[N], y[N], n1, n2, crow[N], ccol[N];
pair<int, int> p[N];
vector<int> row[N], col[N];
vector<vector<int> > srow, scol;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d%d", x + i, y + i);
  }
  for (int i = 0; i < n; i++) p[i] = make_pair(x[i], y[i]);
  sort(p, p + n);
  for (int i = 0; i < n; i++) {
    srow.push_back(
        vector<int>{2 * p[i].first, 2 * p[i].second - 1, 2 * p[i].second + 1});
    scol.push_back(
        vector<int>{2 * p[i].second, 2 * p[i].first - 1, 2 * p[i].first + 1});
  }
  for (int i = 0; i < n - 1; i++)
    if (p[i].first == p[i + 1].first) {
      row[n1++] = vector<int>{2 * p[i].first, 2 * p[i].second + 1,
                              2 * p[i + 1].second - 1};
    }
  for (int i = 0; i < n; i++) p[i] = make_pair(y[i], x[i]);
  sort(p, p + n);
  for (int i = 0; i < n - 1; i++)
    if (p[i].first == p[i + 1].first) {
      col[n2++] = vector<int>{2 * p[i].first, 2 * p[i].second + 1,
                              2 * p[i + 1].second - 1};
    }
  flow::init(n1 + n2, n1 + n2 + 1, n1 + n2 + 2);
  for (int i = 0; i < n1; i++) flow::add(n1 + n2, i, 1);
  for (int i = 0; i < n2; i++) flow::add(n1 + i, n1 + n2 + 1, 1);
  for (int i = 0; i < n1; i++)
    for (int j = 0; j < n2; j++) {
      if (row[i][1] <= col[j][0] && col[j][0] <= row[i][2] &&
          col[j][1] <= row[i][0] && row[i][0] <= col[j][2])
        flow::add(i, j + n1, 1);
    }
  flow::sap();
  for (int i = 0; i < n1; i++) crow[i] = flow::vis[i];
  for (int i = 0; i < n2; i++) ccol[i] = !flow::vis[i + n1];
  for (int i = 0; i < n1; i++)
    if (crow[i]) {
      vector<int> pl, pr;
      for (vector<vector<int> >::iterator it = srow.begin(); it != srow.end();
           it++)
        if ((*it)[0] == row[i][0] && (*it)[2] == row[i][1]) {
          pl = *it;
          srow.erase(it);
          break;
        }
      for (vector<vector<int> >::iterator it = srow.begin(); it != srow.end();
           it++)
        if ((*it)[0] == row[i][0] && (*it)[1] == row[i][2]) {
          pr = *it;
          srow.erase(it);
          break;
        }
      assert(((int)(pl).size()) == 3 && ((int)(pr).size()) == 3);
      srow.push_back(vector<int>{pl[0], pl[1], pr[2]});
    }
  for (int i = 0; i < n2; i++)
    if (ccol[i]) {
      vector<int> pl, pr;
      for (vector<vector<int> >::iterator it = scol.begin(); it != scol.end();
           it++)
        if ((*it)[0] == col[i][0] && (*it)[2] == col[i][1]) {
          pl = *it;
          scol.erase(it);
          break;
        }
      for (vector<vector<int> >::iterator it = scol.begin(); it != scol.end();
           it++)
        if ((*it)[0] == col[i][0] && (*it)[1] == col[i][2]) {
          pr = *it;
          scol.erase(it);
          break;
        }
      assert(((int)(pl).size()) == 3 && ((int)(pr).size()) == 3);
      scol.push_back(vector<int>{pl[0], pl[1], pr[2]});
    }
  printf("%d\n", ((int)(scol).size()));
  for (auto p : scol)
    printf("%d %d %d %d\n", (p[1] + 1) / 2, p[0] / 2, (p[2] - 1) / 2, p[0] / 2);
  printf("%d\n", ((int)(srow).size()));
  for (auto p : srow)
    printf("%d %d %d %d\n", p[0] / 2, (p[1] + 1) / 2, p[0] / 2, (p[2] - 1) / 2);
}