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 point {
  int x, y, id;
} h[1010];
struct noed {
  int t, v, op, next;
} a[2500010];
pair<int, int> h1[1010], h2[1010];
queue<int> q;
int fa[1010], L[1010], R[1010];
int head[2010], cur[2010], level[2010], X[1010], Y[1010], n, vs, vt, t1, t2,
    tot;
bool vis[2010];
inline int rd() {
  int x = 0;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    ;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x;
}
inline void print(int x) {
  static char s[233];
  if (!x) {
    putchar('0');
    putchar(' ');
    return;
  }
  int tot = 0;
  for (; x; x /= 10) s[++tot] = x % 10 + '0';
  for (; tot; tot--) putchar(s[tot]);
  putchar(' ');
}
inline bool cmp1(const point &x, const point &y) {
  return (x.x != y.x) ? x.x < y.x : x.y < y.y;
}
inline bool cmp2(const point &x, const point &y) {
  return (x.y != y.y) ? x.y < y.y : x.x < y.x;
}
inline void add(int x, int y, int z) {
  a[++tot].t = y;
  a[tot].v = z;
  a[tot].op = tot + 1;
  a[tot].next = head[x];
  head[x] = tot;
  a[++tot].t = x;
  a[tot].v = 0;
  a[tot].op = tot - 1;
  a[tot].next = head[y];
  head[y] = tot;
}
inline bool bfs() {
  while (!q.empty()) q.pop();
  memset(level, 0, sizeof(level));
  level[vs] = 1;
  q.push(vs);
  cur[vs] = head[vs];
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i; i = a[i].next) {
      int t = a[i].t;
      if (level[t] || !a[i].v) continue;
      level[t] = level[x] + 1;
      cur[t] = head[t];
      if (t == vt) return true;
      q.push(t);
    }
  }
  return false;
}
inline int dfs(int x, int y) {
  if (x == vt || !y) return y;
  int res = 0;
  for (int &i = cur[x]; i; i = a[i].next) {
    int t = a[i].t;
    if (level[t] != level[x] + 1 || !a[i].v) continue;
    int hh = dfs(t, min(y, a[i].v));
    if (!hh) continue;
    res += hh;
    y -= hh;
    a[i].v -= hh;
    a[a[i].op].v += hh;
  }
  if (!res) level[x] = 0;
  return res;
}
inline void gao(int x) {
  vis[x] = true;
  for (int i = head[x]; i; i = a[i].next) {
    int t = a[i].t;
    if (!a[i].v || vis[t]) continue;
    gao(t);
  }
}
inline int find(int x) { return (x == fa[x]) ? x : fa[x] = find(fa[x]); }
int main() {
  n = rd();
  for (int i = 1; i <= n; i++)
    h[i].x = rd(), h[i].y = rd(), h[i].id = i, X[i] = h[i].x, Y[i] = h[i].y;
  t1 = t2 = 0;
  sort(h + 1, h + n + 1, cmp1);
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && h[j].x == h[i].x; j++)
      ;
    for (int k = i; k < j - 1; k++)
      h1[++t1] = pair<int, int>(h[k].id, h[k + 1].id);
  }
  sort(h + 1, h + n + 1, cmp2);
  for (int i = 1, j; i <= n; i = j) {
    for (j = i; j <= n && h[j].y == h[i].y; j++)
      ;
    for (int k = i; k < j - 1; k++)
      h2[++t2] = pair<int, int>(h[k].id, h[k + 1].id);
  }
  vs = 0;
  vt = t1 + t2 + 1;
  for (int i = 1; i <= t1; i++) add(vs, i, 1);
  for (int i = 1; i <= t2; i++) add(i + t1, vt, 1);
  for (int i = 1; i <= t1; i++)
    for (int j = 1; j <= t2; j++)
      if (X[h1[i].first] > X[h2[j].first] && X[h1[i].first] < X[h2[j].second] &&
          Y[h2[j].first] > Y[h1[i].first] && Y[h2[j].first] < Y[h1[i].second])
        add(i, j + t1, 2123333333);
  while (bfs()) dfs(vs, 2123333333);
  gao(vs);
  for (int i = 1; i <= n; i++) fa[i] = i, L[i] = R[i] = X[i];
  for (int i = 1; i <= t2; i++)
    if (!vis[t1 + i]) {
      int f1 = find(h2[i].first), f2 = find(h2[i].second);
      if (f1 != f2)
        fa[f1] = f2, L[f2] = min(L[f1], L[f2]), R[f2] = max(R[f1], R[f2]);
    }
  int tt = 0;
  for (int i = 1; i <= n; i++)
    if (find(i) == i) tt++;
  print(tt);
  putchar('\n');
  for (int i = 1; i <= n; i++)
    if (find(i) == i)
      print(L[i]), print(Y[i]), print(R[i]), print(Y[i]), putchar('\n');
  for (int i = 1; i <= n; i++) fa[i] = i, L[i] = R[i] = Y[i];
  for (int i = 1; i <= t1; i++)
    if (vis[i]) {
      int f1 = find(h1[i].first), f2 = find(h1[i].second);
      if (f1 != f2)
        fa[f1] = f2, L[f2] = min(L[f1], L[f2]), R[f2] = max(R[f1], R[f2]);
    }
  tt = 0;
  for (int i = 1; i <= n; i++)
    if (find(i) == i) tt++;
  print(tt);
  putchar('\n');
  for (int i = 1; i <= n; i++)
    if (find(i) == i)
      print(X[i]), print(L[i]), print(X[i]), print(R[i]), putchar('\n');
  return 0;
}