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 = 1000;
vector<pair<pair<int, int>, pair<int, int>>> hor, ver;
vector<int> G[MAXN + 5];
int Lmate[MAXN + 5];
int Rmate[MAXN + 5];
bool vis[MAXN + 5];
bool flag[MAXN + 5][2];
bool inMvc[MAXN + 5][2];
pair<int, int> arr[MAXN + 5];
map<int, vector<int>> Xs, Ys;
map<int, vector<int>> Xis, Yis;
int n;
void fillNeighbors() {
  for (auto& p : Xs) {
    int second = p.first;
    auto& is = Xis[second];
    for (int i = 0; i + 1 < p.second.size(); i++) {
      int first = p.second[i];
      int X2 = p.second[i + 1];
      is.push_back(hor.size());
      hor.push_back({{first, second}, {X2, second}});
    }
  }
  for (auto& p : Ys) {
    int first = p.first;
    auto& is = Yis[first];
    for (int i = 0; i + 1 < p.second.size(); i++) {
      int second = p.second[i];
      int Y2 = p.second[i + 1];
      is.push_back(ver.size());
      ver.push_back({{first, second}, {first, Y2}});
    }
  }
}
void buildGraph() {
  int i = 0;
  for (auto& h : hor) {
    int j = 0;
    for (auto& v : ver) {
      if (h.first.first < v.first.first && h.second.first > v.first.first &&
          v.first.second < h.first.second && v.second.second > h.first.second) {
        G[i].push_back(j);
      }
      j++;
    }
    i++;
  }
}
bool match(int u) {
  if (vis[u]) return false;
  vis[u] = 1;
  for (int v : G[u]) {
    if (Rmate[v] == -1 || match(Rmate[v])) {
      Lmate[u] = v;
      Rmate[v] = u;
      return true;
    }
  }
  return false;
}
int maxMatching() {
  memset(Lmate, -1, sizeof(Lmate));
  memset(Rmate, -1, sizeof(Rmate));
  int ret = 0;
  for (int c = 0; c < hor.size(); c++) {
    memset(vis, 0, sizeof(vis));
    ret += match(c);
  }
  return ret;
}
void dfs(int u, bool side) {
  if (flag[u][side]) return;
  flag[u][side] = 1;
  vector<int>&& children = side == 0 ? move(G[u]) : (vector<int>){Rmate[u]};
  for (int v : children) dfs(v, !side);
}
void minVertexCover() {
  memset(inMvc, 0, sizeof(inMvc));
  memset(flag, 0, sizeof(flag));
  for (int i = 0; i < hor.size(); i++) {
    if (!~Lmate[i]) dfs(i, 0);
  }
  for (int i = 0; i < hor.size(); i++) inMvc[i][0] = !flag[i][0];
  for (int i = 0; i < ver.size(); i++) inMvc[i][1] = flag[i][1];
}
void addSegment(vector<pair<pair<int, int>, pair<int, int>>>& ret,
                const pair<pair<int, int>, pair<int, int>>& segment) {
  if (ret.empty() || ret.back().second != segment.first)
    ret.push_back(segment);
  else
    ret.back().second = segment.second;
}
vector<pair<pair<int, int>, pair<int, int>>> solve(
    map<int, vector<int>>& Xs, map<int, vector<int>>& Xis,
    const vector<pair<pair<int, int>, pair<int, int>>>& hor, int side) {
  vector<pair<pair<int, int>, pair<int, int>>> ret;
  for (const auto& p : Xs) {
    int second = p.first;
    const auto& is = Xis[second];
    for (int i = 0; i < is.size(); i++) {
      int ix = is[i];
      if (inMvc[ix][side])
        addSegment(ret, {hor[ix].first, hor[ix].first});
      else
        addSegment(ret, hor[ix]);
    }
    pair<int, int> lastPoint = {p.second.back(), second};
    if (side == 1) swap(lastPoint.first, lastPoint.second);
    addSegment(ret, {lastPoint, lastPoint});
  }
  return ret;
}
void printSegments(
    const vector<pair<pair<int, int>, pair<int, int>>>& segments) {
  printf("%d\n", segments.size());
  for (const auto& segment : segments) {
    printf("%d %d %d %d\n", segment.first.first, segment.first.second,
           segment.second.first, segment.second.second);
  }
}
int main() {
  scanf("%d", &n);
  int c, c2;
  for (c = 0; c < n; c++) {
    scanf("%d%d", &arr[c].first, &arr[c].second);
    Xs[arr[c].second].push_back(arr[c].first);
    Ys[arr[c].first].push_back(arr[c].second);
  }
  for (auto& p : Xs) sort(p.second.begin(), p.second.end());
  for (auto& p : Ys) sort(p.second.begin(), p.second.end());
  fillNeighbors();
  buildGraph();
  maxMatching();
  minVertexCover();
  vector<pair<pair<int, int>, pair<int, int>>> horAns = solve(Xs, Xis, hor, 0);
  vector<pair<pair<int, int>, pair<int, int>>> verAns = solve(Ys, Yis, ver, 1);
  printSegments(horAns);
  printSegments(verAns);
}