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;
struct Edge {
  int to, flow, next;
} e[3000050];
int n, now, maxflow, ansrs, anscs, S, T, first[2222], last[2222], q[2222],
    level[2222], arrx[2222], arry[2222];
int rows, cols;
bool temp[2222][2222], have[2222][2222], isS[2222], user[2222], usec[2222];
pair<int, int> p[2222], d[2222];
pair<int, pair<int, int> > row[2222], col[2222];
pair<pair<int, int>, pair<int, int> > ansr[2222 * 2222], ansc[2222 * 2222];
void Add(int u, int v, int w) {
  e[++now].to = v;
  e[now].flow = w;
  e[now].next = first[u];
  first[u] = now;
}
bool Level() {
  int low, high, pt, next;
  memset(level, -1, sizeof(level));
  q[low = high = 0] = S;
  level[S] = 0;
  for (; low <= high; low++)
    for (pt = first[q[low]]; pt != -1; pt = e[pt].next) {
      next = e[pt].to;
      if (level[next] != -1 || e[pt].flow <= 0) continue;
      level[next] = level[q[low]] + 1;
      q[++high] = next;
      if (next == T) return true;
    }
  return false;
}
int Find(int first, int delta) {
  int pt, next, temp, res = 0;
  if (first == T || delta <= 0) return delta;
  for (pt = last[first]; pt != -1; last[first] = pt = e[pt].next) {
    next = e[pt].to;
    if (level[next] != level[first] + 1) continue;
    temp = Find(next, min(delta, e[pt].flow));
    delta -= temp;
    res += temp;
    e[pt].flow -= temp;
    e[pt ^ 1].flow += temp;
    if (delta <= 0) return res;
  }
  return res;
}
void BFS() {
  int low, high, pt, next;
  memset(isS, false, sizeof(isS));
  q[low = high = 0] = S;
  isS[S] = true;
  for (; low <= high; low++)
    for (pt = first[q[low]]; pt != -1; pt = e[pt].next) {
      next = e[pt].to;
      if (isS[next] || e[pt].flow <= 0) continue;
      isS[next] = true;
      q[++high] = next;
    }
}
void Output(pair<pair<int, int>, pair<int, int> > pa) {
  printf("%d %d %d %d\n", arrx[pa.first.first], arry[pa.first.second],
         arrx[pa.second.first], arry[pa.second.second]);
}
int main() {
  int i, j, rec, arrxs, arrys, pt, next;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    scanf("%d%d", &p[i].first, &p[i].second), arrx[i] = p[i].first,
                                              arry[i] = p[i].second;
  sort(arrx + 1, arrx + n + 1);
  arrxs = unique(arrx + 1, arrx + n + 1) - arrx - 1;
  sort(arry + 1, arry + n + 1);
  arrys = unique(arry + 1, arry + n + 1) - arry - 1;
  for (i = 1; i <= n; i++) {
    d[i].first = lower_bound(arrx + 1, arrx + arrxs + 1, p[i].first) - arrx;
    d[i].second = lower_bound(arry + 1, arry + arrys + 1, p[i].second) - arry;
    have[d[i].first][d[i].second] = true;
  }
  for (i = 1; i <= arrxs; i++) {
    rec = -1;
    for (j = 1; j <= arrys; j++)
      if (have[i][j]) {
        if (rec != -1 && rec + 1 < j)
          row[++rows] = make_pair(i, make_pair(rec + 1, j - 1));
        rec = j;
      }
  }
  for (j = 1; j <= arrys; j++) {
    rec = -1;
    for (i = 1; i <= arrxs; i++)
      if (have[i][j]) {
        if (rec != -1 && rec + 1 < i)
          col[++cols] = make_pair(j, make_pair(rec + 1, i - 1));
        rec = i;
      }
  }
  S = 0;
  T = rows + cols + 1;
  memset(first, -1, sizeof(first));
  now = -1;
  for (i = 1; i <= rows; i++) Add(S, i, 1), Add(i, S, 0);
  for (i = 1; i <= cols; i++) Add(rows + i, T, 1), Add(T, rows + i, 0);
  for (i = 1; i <= rows; i++)
    for (j = 1; j <= cols; j++)
      if (col[j].second.first <= row[i].first &&
          row[i].first <= col[j].second.second &&
          row[i].second.first <= col[j].first &&
          col[j].first <= row[i].second.second)
        Add(i, rows + j, 999999999), Add(rows + j, i, 0);
  while (Level()) {
    memcpy(last, first, sizeof(last));
    maxflow += Find(S, 999999999);
  }
  BFS();
  memset(user, true, sizeof(user));
  memset(usec, true, sizeof(usec));
  for (i = S; i <= T; i++)
    if (isS[i])
      for (pt = first[i]; pt != -1; pt = e[pt].next) {
        next = e[pt].to;
        if (isS[next]) continue;
        if (i == S)
          user[next] = false;
        else
          usec[i - rows] = false;
      }
  memcpy(temp, have, sizeof(temp));
  for (i = 1; i <= cols; i++)
    if (usec[i])
      for (j = col[i].second.first; j <= col[i].second.second; j++)
        temp[j][col[i].first] = true;
  for (j = 1; j <= arrys; j++) {
    rec = 0;
    for (i = 1; i <= arrxs; i++)
      if (!temp[i][j]) {
        if (rec + 1 < i)
          ansc[++anscs] = make_pair(make_pair(rec + 1, j), make_pair(i - 1, j));
        rec = i;
      }
    if (rec < arrxs)
      ansc[++anscs] = make_pair(make_pair(rec + 1, j), make_pair(arrxs, j));
  }
  memcpy(temp, have, sizeof(temp));
  for (i = 1; i <= rows; i++)
    if (user[i])
      for (j = row[i].second.first; j <= row[i].second.second; j++)
        temp[row[i].first][j] = true;
  for (i = 1; i <= arrxs; i++) {
    rec = 0;
    for (j = 1; j <= arrys; j++)
      if (!temp[i][j]) {
        if (rec + 1 < j)
          ansr[++ansrs] = make_pair(make_pair(i, rec + 1), make_pair(i, j - 1));
        rec = j;
      }
    if (rec < arrys)
      ansr[++ansrs] = make_pair(make_pair(i, rec + 1), make_pair(i, arrys));
  }
  printf("%d\n", anscs);
  for (i = 1; i <= anscs; i++) Output(ansc[i]);
  printf("%d\n", ansrs);
  for (i = 1; i <= ansrs; i++) Output(ansr[i]);
  return 0;
}