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 dot {
  long long x, y, pos;
} a[2005], b[2005];
struct edge {
  long long to, nxt, val;
} e[2000005 << 1];
queue<long long> q;
long long j, aaa, las, pp[2005], val, vv[2005], vst[2005], node[2005],
    nxt[2005], cur[2005], dis[2005], s, t, tot = 1;
inline void add(long long x, long long y, long long v) {
  e[++tot].nxt = node[x];
  e[tot].to = y;
  e[tot].val = v;
  node[x] = tot;
}
inline void ADD(long long x, long long y) {
  add(x, y, 1);
  add(y, x, 0);
}
inline long long min(long long x, long long y) { return x < y ? x : y; }
inline long long bfs() {
  q.push(s);
  memset(dis, -1, sizeof(dis));
  dis[s] = 0;
  long long now, i, to;
  while (q.size()) {
    now = q.front();
    q.pop();
    for (i = node[now]; i; i = e[i].nxt) {
      to = e[i].to;
      if ((!e[i].val) || (~dis[to])) {
        continue;
      }
      dis[to] = dis[now] + 1;
      q.push(to);
    }
  }
  return ~dis[t];
}
long long dfs(long long now, long long flow) {
  if (now == t) return flow;
  long long qwq, flown = 0, &i = cur[now], to;
  for (; i; i = e[i].nxt) {
    to = e[i].to;
    if (dis[to] == dis[now] + 1 && e[i].val) {
      qwq = dfs(to, min(e[i].val, flow));
      flow -= qwq;
      flown += qwq;
      e[i].val -= qwq;
      e[i ^ 1].val += qwq;
      if (!flow) return flown;
    }
  }
  return flown;
}
inline long long dinic() {
  long long ret = 0;
  while (bfs()) {
    memcpy(cur, node, sizeof(node));
    ret += dfs(s, 1e9);
  }
  return ret;
}
long long n, m, i, x, y, v;
inline bool cmp(dot aa, dot bb) {
  if (aa.x == bb.x) return aa.y < bb.y;
  return aa.x < bb.x;
}
inline bool CMP(dot aa, dot bb) {
  if (aa.y == bb.y) return aa.x < bb.x;
  return aa.y < bb.y;
}
void Dfs(long long now) {
  vst[now] = 1;
  if (now > n) {
    for (long long i = node[now]; i; i = e[i].nxt) {
      if (e[i].to <= n && pp[e[i].to] != now && !vst[e[i].to]) Dfs(e[i].to);
    }
  } else {
    if (!vst[pp[now]]) Dfs(pp[now]);
  }
}
map<long long, long long> p;
signed main() {
  cin >> n;
  for (i = 1; i <= n; ++i)
    cin >> a[i].x >> a[i].y, a[i].pos = i, b[i] = a[i],
                             p[a[i].x * 2000000000ll + a[i].y] = 1;
  sort(a + 1, a + n + 1, cmp);
  sort(b + 1, b + n + 1, CMP);
  for (i = 1; i <= n; ++i) {
    if (a[i].x == a[i + 1].x) nxt[a[i].pos] = a[i + 1].pos;
  }
  s = 0;
  t = n + n + 1;
  for (i = 1; i <= n; ++i) ADD(s, i), ADD(n + i, t);
  for (i = 1; i <= n; ++i) {
    if (b[i].y == b[i + 1].y) {
      for (j = 1; j <= n; ++j)
        if (nxt[a[j].pos] && a[j].x < b[i + 1].x && a[j].x > b[i].x &&
            b[i].y > a[j].y && b[i].y < a[j + 1].y &&
            !p[a[j].x * 2000000000ll + b[i].y]) {
          ADD(a[j].pos, b[i].pos + n);
        }
    }
  }
  dinic();
  for (i = 1; i <= n; ++i) {
    for (j = node[i]; j; j = e[j].nxt) {
      if (e[j].to && e[j ^ 1].val) {
        pp[i] = e[j].to;
        vv[e[j].to] = 1;
      }
    }
  }
  for (i = n + 1; i <= n + n; ++i) {
    if (!vv[i] && !vst[i]) Dfs(i);
  }
  for (i = las = 1; i <= n; ++i) {
    if (b[i].y != b[i + 1].y || !vst[b[i].pos + n]) ++aaa;
  }
  cout << aaa << "\n";
  for (i = las = 1; i <= n; ++i) {
    if (b[i].y != b[i + 1].y || !vst[b[i].pos + n])
      cout << b[las].x << " " << b[las].y << " " << b[i].x << " " << b[i].y
           << "\n",
          las = i + 1;
  }
  aaa = 0;
  for (i = las = 1; i <= n; ++i) {
    if (a[i].x != a[i + 1].x || vst[a[i].pos]) ++aaa;
  }
  cout << aaa << "\n";
  for (i = las = 1; i <= n; ++i) {
    if (a[i].x != a[i + 1].x || vst[a[i].pos])
      cout << a[las].x << " " << a[las].y << " " << a[i].x << " " << a[i].y
           << "\n",
          las = i + 1;
  }
}