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 Maxn = 2005;
int n, ct, ct1, ct2, cnt, ans_ct, head[Maxn], cur[Maxn], dis[Maxn], x[Maxn],
    y[Maxn], tmp[Maxn];
pair<pair<int, int>, pair<int, int> > e[Maxn], ans[Maxn];
bool vis[Maxn];
map<pair<pair<int, int>, pair<int, int> >, int> Ma1, Ma2;
vector<pair<int, int> > Ve1[Maxn], Ve2[Maxn];
bool cross(pair<pair<int, int>, pair<int, int> > x,
           pair<pair<int, int>, pair<int, int> > y) {
  return y.first.second > x.first.second && y.first.second < x.second.second &&
         x.first.first > y.first.first && x.first.first < y.second.first;
}
struct edg {
  int nxt, to, w;
} edge[Maxn * Maxn];
void add(int x, int y) {
  edge[++cnt] = (edg){head[x], y, 1};
  head[x] = cnt;
  edge[++cnt] = (edg){head[y], x, 0};
  head[y] = cnt;
}
queue<int> Qu;
bool bfs(void) {
  Qu.push(ct2 + 1);
  memset(dis, 0, sizeof(int[ct2 + 3]));
  while (!Qu.empty()) {
    int u = Qu.front();
    Qu.pop();
    for (int i = head[u]; i; i = edge[i].nxt) {
      int to = edge[i].to;
      if (to != ct2 + 1 && !dis[to] && edge[i].w) {
        dis[to] = dis[u] + 1;
        Qu.push(to);
      }
    }
  }
  return dis[ct2 + 2];
}
int dfs(int u, int mini) {
  if (u == ct2 + 2 || !mini) return mini;
  int w, used = 0;
  for (int& i = cur[u]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (dis[u] + 1 == dis[to] && edge[i].w) {
      w = dfs(to, min(mini - used, edge[i].w));
      used += w, edge[i].w -= w, edge[((i - 1) ^ 1) + 1].w += w;
      if (used == mini) return used;
    }
  }
  return used;
}
void dinic(void) {
  while (bfs()) {
    memcpy(cur, head, sizeof(int[ct2 + 3]));
    dfs(ct2 + 1, 0x3f3f3f3f);
  }
}
void DFS(int u) {
  vis[u] = true;
  for (int i = head[u]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (!vis[to] && !edge[i].w) DFS(to);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++)
    scanf("%d%d", &x[i], &y[i]), tmp[++ct] = x[i], tmp[++ct] = y[i];
  sort(tmp + 1, tmp + 1 + 2 * n);
  ct = unique(tmp + 1, tmp + 1 + 2 * n) - tmp - 1;
  for (int i = 1; i <= n; i++) {
    x[i] = lower_bound(tmp + 1, tmp + 1 + ct, x[i]) - tmp;
    y[i] = lower_bound(tmp + 1, tmp + 1 + ct, y[i]) - tmp;
    Ve1[x[i]].push_back(make_pair(x[i], y[i]));
    Ve2[y[i]].push_back(make_pair(x[i], y[i]));
  }
  for (int i = 1; i <= ct; i++)
    sort(Ve1[i].begin(), Ve1[i].end()), sort(Ve2[i].begin(), Ve2[i].end());
  for (int i = 1; i <= ct; i++)
    for (int j = 0; j < (int)Ve1[i].size() - 1; j++) {
      Ma1[make_pair(Ve1[i][j], Ve1[i][j + 1])] = ++ct1;
      e[ct1] = make_pair(Ve1[i][j], Ve1[i][j + 1]);
    }
  ct2 = ct1;
  for (int i = 1; i <= ct; i++)
    for (int j = 0; j < (int)Ve2[i].size() - 1; j++) {
      Ma2[make_pair(Ve2[i][j], Ve2[i][j + 1])] = ++ct2;
      e[ct2] = make_pair(Ve2[i][j], Ve2[i][j + 1]);
    }
  for (int i = 1; i <= ct1; i++)
    for (int j = ct1 + 1; j <= ct2; j++)
      if (cross(e[i], e[j])) add(i, j);
  for (int i = 1; i <= ct1; i++) add(ct2 + 1, i);
  for (int i = ct1 + 1; i <= ct2; i++) add(i, ct2 + 2);
  dinic();
  for (int i = head[ct2 + 2]; i; i = edge[i].nxt) {
    int to = edge[i].to;
    if (!edge[i].w) DFS(to);
  }
  for (int i = head[ct2 + 1]; i; i = edge[i].nxt) vis[edge[i].to] ^= 1;
  pair<int, int> las;
  for (int i = 1; i <= ct; i++) {
    if (Ve2[i].size()) las = Ve2[i][0];
    for (int j = 0; j < (int)Ve2[i].size() - 1; j++)
      if (!vis[Ma2[make_pair(Ve2[i][j], Ve2[i][j + 1])]])
        ans[++ans_ct] = make_pair(las, Ve2[i][j]), las = Ve2[i][j + 1];
    if (Ve2[i].size()) ans[++ans_ct] = make_pair(las, *Ve2[i].rbegin());
  }
  printf("%d\n", ans_ct);
  for (int i = 1; i <= ans_ct; i++)
    printf("%d %d %d %d\n", tmp[ans[i].first.first], tmp[ans[i].first.second],
           tmp[ans[i].second.first], tmp[ans[i].second.second]);
  ans_ct = 0;
  for (int i = 1; i <= ct; i++) {
    if (Ve1[i].size()) las = Ve1[i][0];
    for (int j = 0; j < (int)Ve1[i].size() - 1; j++)
      if (!vis[Ma1[make_pair(Ve1[i][j], Ve1[i][j + 1])]])
        ans[++ans_ct] = make_pair(las, Ve1[i][j]), las = Ve1[i][j + 1];
    if (Ve1[i].size()) ans[++ans_ct] = make_pair(las, *Ve1[i].rbegin());
  }
  printf("%d\n", ans_ct);
  for (int i = 1; i <= ans_ct; i++)
    printf("%d %d %d %d\n", tmp[ans[i].first.first], tmp[ans[i].first.second],
           tmp[ans[i].second.first], tmp[ans[i].second.second]);
  return 0;
}