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 int N = 10010;
const int M = 2e6 + 10;
const int inf = 0x3f3f3f3;
int head[N], d[N], cur[N];
int n, m, s, t, tot;
queue<int> q;
struct EDGE {
  int to, nx, c;
} e[M * 2];
void add(int u, int v, int z) {
  e[tot].to = v;
  e[tot].nx = head[u];
  e[tot].c = z;
  head[u] = tot++;
  e[tot].to = u;
  e[tot].nx = head[v];
  e[tot].c = 0;
  head[v] = tot++;
}
bool bfs(int s, int t) {
  memset(d, 0, sizeof(d));
  while (q.size()) q.pop();
  for (int i = 1; i <= t; i++) cur[i] = head[i];
  q.push(s);
  d[s] = 1;
  while (q.size()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i != -1; i = e[i].nx) {
      int y = e[i].to;
      if (e[i].c && !d[y]) {
        q.push(y);
        d[y] = d[x] + 1;
        if (y == t) return 1;
      }
    }
  }
  return 0;
}
int dfs(int x, int flow) {
  if (x == t) return flow;
  int rest = flow, k;
  for (int i = cur[x]; i != -1 && rest; i = e[i].nx) {
    cur[x] = i;
    int y = e[i].to, z = e[i].c;
    if (z && d[y] == d[x] + 1) {
      k = dfs(y, min(rest, z));
      if (!k) d[y] = 0;
      e[i].c -= k;
      e[i ^ 1].c += k;
      rest -= k;
    }
  }
  return flow - rest;
}
int dinic(int s, int t) {
  int flow = 0, maxflow = 0;
  while (bfs(s, t))
    while (flow = dfs(s, inf)) maxflow += flow;
  return maxflow;
}
void init() {
  for (int i = 1; i <= t; i++) head[i] = -1;
  tot = 0;
}
bool cmp1(pair<int, int> x, pair<int, int> y) {
  if (x.first == y.first) return x.second < y.second;
  return x.first < y.first;
}
bool cmp2(pair<int, int> x, pair<int, int> y) {
  if (x.second == y.second) return x.first < y.first;
  return x.second < y.second;
}
bool cmp3(pair<pair<int, int>, pair<int, int> > x,
          pair<pair<int, int>, pair<int, int> > y) {
  if (x.first.first == y.first.first) return x.first.second < y.first.second;
  return x.first.first < y.first.first;
}
bool cmp4(pair<pair<int, int>, pair<int, int> > x,
          pair<pair<int, int>, pair<int, int> > y) {
  if (x.first.second == y.first.second) return x.first.first < y.first.first;
  return x.first.second < y.first.second;
}
pair<int, int> x[1010];
map<pair<pair<int, int>, pair<int, int> >, int> mp;
pair<pair<int, int>, pair<int, int> > sj[10100];
vector<pair<pair<int, int>, pair<int, int> > > op, ans;
int tid = 1, pp;
bool ison(pair<pair<int, int>, pair<int, int> > a,
          pair<pair<int, int>, pair<int, int> > b) {
  if (b.first.first > a.first.first && b.first.first < a.second.first &&
      a.first.second > b.first.second && a.first.second < b.second.second)
    return true;
  return false;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &x[i].first, &x[i].second);
  }
  sort(x + 1, x + 1 + n, cmp2);
  for (int i = 2; i <= n; i++) {
    if (x[i].second == x[i - 1].second) {
      mp[{x[i - 1], x[i]}] = tid;
      sj[tid++] = {x[i - 1], x[i]};
    }
  }
  pp = tid;
  sort(x + 1, x + 1 + n, cmp1);
  for (int i = 2; i <= n; i++) {
    if (x[i].first == x[i - 1].first) {
      mp[{x[i - 1], x[i]}] = tid;
      sj[tid++] = {x[i - 1], x[i]};
    }
  }
  s = tid;
  t = s + 1;
  init();
  for (int i = 1; i < pp; i++) add(s, i, 1);
  for (int i = pp; i < s; i++) add(i, t, 1);
  for (int i = 1; i < pp; i++) {
    for (int j = pp; j < s; j++) {
      if (ison(sj[i], sj[j])) add(i, j, inf);
    }
  }
  dinic(s, t);
  for (int i = 1; i <= n; i++) ans.push_back({x[i], x[i]});
  for (int i = head[s]; i != -1; i = e[i].nx) {
    if (d[e[i].to]) ans.push_back(sj[e[i].to]);
  }
  sort(ans.begin(), ans.end(), cmp4);
  pair<int, int> st = ans[0].first, ed = ans[0].second;
  for (int i = 1; i < ans.size(); i++) {
    if (ans[i].first.second == ed.second && ans[i].first.first <= ed.first) {
      ed.first = max(ed.first, ans[i].second.first);
    } else {
      op.push_back({st, ed});
      st = ans[i].first;
      ed = ans[i].second;
    }
  }
  op.push_back({st, ed});
  printf("%d\n", op.size());
  for (int i = 0; i < op.size(); i++)
    printf("%d %d %d %d\n", op[i].first.first, op[i].first.second,
           op[i].second.first, op[i].second.second);
  ans.clear();
  op.clear();
  for (int i = 1; i <= n; i++) ans.push_back({x[i], x[i]});
  for (int i = head[t]; i != -1; i = e[i].nx) {
    if (d[e[i].to] == 0) ans.push_back(sj[e[i].to]);
  }
  sort(ans.begin(), ans.end(), cmp3);
  st = ans[0].first, ed = ans[0].second;
  for (int i = 1; i < ans.size(); i++) {
    if (ans[i].first.first == ed.first && ans[i].first.second <= ed.second) {
      ed.second = max(ed.second, ans[i].second.second);
    } else {
      op.push_back({st, ed});
      st = ans[i].first;
      ed = ans[i].second;
    }
  }
  op.push_back({st, ed});
  printf("%d\n", op.size());
  for (int i = 0; i < op.size(); i++)
    printf("%d %d %d %d\n", op[i].first.first, op[i].first.second,
           op[i].second.first, op[i].second.second);
}