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;
uint64_t rnd_data = 0xDEADBEEFDULL;
inline void my_srand(int seed) { rnd_data = ((uint64_t)seed << 16) | 0x330E; }
inline int my_rand() {
  rnd_data = rnd_data * 0x5DEECE66DULL + 0xB;
  return (rnd_data >> 17) & 0x7FFFFFFF;
}
template <typename T>
void my_random_shuffle(T b, T e) {
  for (int i = (1); i <= (int)((int)(e - b) - 1); i++) {
    swap(b[i], b[my_rand() % (i + 1)]);
  }
}
template <class _T>
inline _T sqr(const _T &x) {
  return x * x;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uin(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(b, a) ? a = b, true : false;
}
template <typename type_t, typename less_t = std::less<type_t>>
inline bool uax(type_t &a, const type_t &b, const less_t &ls = less_t()) {
  return ls(a, b) ? a = b, true : false;
}
const long double PI = 3.1415926535897932384626433832795L;
const long double EPS = 1e-9;
struct tp {
  int x, y;
};
int n, xx = 0, yy = 0;
tp p[1024];
int xs[1024];
int ys[1024];
bool b[1024][1024];
int xr[1024][2];
int yr[1024][2];
int kh, kv;
int nh[1024][1024];
int nv[1024][1024];
vector<int> a[10240];
vector<int> ra[10240];
bool u[10240];
int p1[10240];
int pa[10240];
bool u2[10240];
int ah[10240][4];
int av[10240][4];
bool bh[1024][1024];
bool bv[1024][1024];
bool find(int k) {
  u[k] = true;
  for (int v : a[k]) {
    if (pa[v] == -1) {
      pa[v] = k;
      return true;
    }
  }
  for (int v : a[k]) {
    if (pa[v] == -1 || (!u[pa[v]] && find(pa[v]))) {
      pa[v] = k;
      return true;
    }
  }
  return false;
}
void dfs(int k) {
  u[k] = true;
  for (int v : a[k]) {
    if (pa[v] == k) continue;
    if (!u2[v]) {
      u2[v] = true;
      dfs(pa[v]);
    }
  }
}
void solve() {
  memset(p1, 0xff, sizeof(p1));
  for (int i = 0; i < (int)(kv); i++) {
    if (pa[i] != -1) {
      p1[pa[i]] = i;
    }
  }
  memset((u), 0, sizeof(u));
  memset((u2), 0, sizeof(u2));
  for (int i = 0; i < (int)(kh); i++) {
    if (p1[i] == -1) {
      dfs(i);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < (int)(n); i++) {
    scanf("%d%d", &p[i].x, &p[i].y);
    xs[xx++] = p[i].x;
    ys[yy++] = p[i].y;
  }
  sort(xs, xs + xx);
  xx = unique(xs, xs + xx) - xs;
  sort(ys, ys + yy);
  yy = unique(ys, ys + yy) - ys;
  for (int i = 0; i < (int)(n); i++) {
    p[i].x = lower_bound(xs, xs + xx, p[i].x) - xs;
    p[i].y = lower_bound(ys, ys + yy, p[i].y) - ys;
  }
  memset((b), 0, sizeof(b));
  for (int i = 0; i < (int)(n); i++) {
    b[p[i].x][p[i].y] = true;
  }
  for (int j = 0; j < (int)(yy); j++) {
    yr[j][0] = xx + 1;
    yr[j][1] = -1;
  }
  for (int i = 0; i < (int)(xx); i++) {
    xr[i][0] = yy + 1;
    xr[i][1] = -1;
    for (int j = 0; j < (int)(yy); j++) {
      if (b[i][j]) {
        uin(xr[i][0], j);
        uax(xr[i][1], j);
        uin(yr[j][0], i);
        uax(yr[j][1], i);
      }
    }
  }
  memset(nh, 0xff, sizeof(nh));
  memset(nv, 0xff, sizeof(nv));
  kh = kv = 0;
  for (int i = 0; i < (int)(xx); i++) {
    if (xr[i][1] < 0) continue;
    int sty = -1;
    for (int j = 0; j < (int)(yy); j++) {
      if (j < xr[i][0] || j > xr[i][1]) continue;
      if (b[i][j]) {
        if (sty != -1) {
          kh++;
          sty = -1;
        }
      } else {
        nh[i][j] = kh;
        sty = j;
      }
    }
    if (sty != -1) {
      kh++;
    }
  }
  for (int j = 0; j < (int)(yy); j++) {
    if (yr[j][1] < 0) continue;
    int stx = -1;
    for (int i = 0; i < (int)(xx); i++) {
      if (i < yr[j][0] || i > yr[j][1]) continue;
      if (b[i][j]) {
        if (stx != -1) {
          kv++;
          stx = -1;
        }
      } else {
        nv[i][j] = kv;
        stx = i;
      }
    }
    if (stx != -1) {
      kv++;
    }
  }
  for (int i = 0; i < (int)(xx); i++) {
    for (int j = 0; j < (int)(yy); j++) {
      if (nh[i][j] != -1) {
        if (nv[i][j] != -1) {
          a[nh[i][j]].push_back(nv[i][j]);
          ra[nv[i][j]].push_back(nh[i][j]);
        }
      }
    }
  }
  memset(pa, 0xff, sizeof(pa));
  memset((u), 0, sizeof(u));
  for (int i = 0; i < (int)(kh); i++) {
    if (find(i)) {
      memset(u, 0, kh * sizeof(u[0]));
    }
  }
  memcpy(bh, b, sizeof(b));
  memcpy(bv, b, sizeof(b));
  solve();
  for (int i = 0; i < (int)(xx); i++) {
    for (int j = 0; j < (int)(yy); j++) {
      if (nh[i][j] >= 0 && u[nh[i][j]]) bh[i][j] = true;
      if (nv[i][j] >= 0 && !u2[nv[i][j]]) bv[i][j] = true;
    }
  }
  int hh = 0, vv = 0;
  for (int i = 0; i < (int)(xx); i++) {
    if (xr[i][1] < 0) continue;
    int st = -1;
    for (int j = 0; j < (int)(yy + 1); j++) {
      if (bh[i][j]) {
        if (st < 0) st = j;
      } else {
        if (st >= 0) {
          ah[hh][0] = i;
          ah[hh][1] = st;
          ah[hh][2] = i;
          ah[hh][3] = j - 1;
          hh++;
          st = -1;
        }
      }
    }
  }
  for (int j = 0; j < (int)(yy); j++) {
    if (yr[j][1] < 0) continue;
    int st = -1;
    for (int i = 0; i < (int)(xx + 1); i++) {
      if (bv[i][j]) {
        if (st < 0) st = i;
      } else {
        if (st >= 0) {
          av[vv][0] = st;
          av[vv][1] = j;
          av[vv][2] = i - 1;
          av[vv][3] = j;
          vv++;
          st = -1;
        }
      }
    }
  }
  printf("%d\n", vv);
  for (int i = 0; i < (int)(vv); i++) {
    for (int j = 0; j < (int)(2); j++) {
      printf("%d %d%c", xs[av[i][j * 2]], ys[av[i][j * 2 + 1]], " \n"[j == 1]);
    }
  }
  printf("%d\n", hh);
  for (int i = 0; i < (int)(hh); i++) {
    for (int j = 0; j < (int)(2); j++) {
      printf("%d %d%c", xs[ah[i][j * 2]], ys[ah[i][j * 2 + 1]], " \n"[j == 1]);
    }
  }
  return 0;
}