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 NMax = 1005;
int N, cntH, cntV;
vector<int> G[NMax];
struct Line {
  int x1, x2, y;
} HorizL[NMax], VertL[NMax];
pair<int, int> P[NMax];
bool Use[NMax];
int L[NMax], R[NMax];
bool UseR[NMax], UseL[NMax];
void Read() {
  cin >> N;
  for (int i = 1; i <= N; i++) cin >> P[i].first >> P[i].second;
}
inline bool cmpOrd(pair<int, int> a, pair<int, int> b) {
  if (a.second == b.second) return a.first < b.first;
  return a.second < b.second;
}
void sortByOrd() { sort(P + 1, P + N + 1, cmpOrd); }
void sortByAbs() { sort(P + 1, P + N + 1); }
void buildHorizLines() {
  sortByOrd();
  for (int i = 1; i < N; i++) {
    if (P[i].second == P[i + 1].second)
      HorizL[++cntH] = {P[i].first, P[i + 1].first, P[i].second};
    else
      HorizL[++cntH] = {P[i].first, P[i].first, P[i].second};
  }
  HorizL[++cntH] = {P[N].first, P[N].first, P[N].second};
}
void buildVertLines() {
  sortByAbs();
  for (int i = 1; i < N; i++) {
    if (P[i].first == P[i + 1].first)
      VertL[++cntV] = {P[i].second, P[i + 1].second, P[i].first};
    else
      VertL[++cntV] = {P[i].second, P[i].second, P[i].first};
  }
  VertL[++cntV] = {P[N].second, P[N].second, P[N].first};
}
inline bool Intersects(int horiz, int vert) {
  return HorizL[horiz].y > VertL[vert].x1 && HorizL[horiz].y < VertL[vert].x2 &&
         VertL[vert].y > HorizL[horiz].x1 && VertL[vert].y < HorizL[horiz].x2;
}
void buildGraph() {
  for (int i = 1; i <= cntH; i++) {
    for (int j = 1; j <= cntV; j++)
      if (Intersects(i, j)) {
        G[i].push_back(j);
      }
  }
}
bool pairup(int n) {
  unsigned int i = 0;
  if (Use[n] == 1) return 0;
  Use[n] = 1;
  for (i = 0; i < G[n].size(); i++) {
    int vecin = G[n][i];
    if (R[vecin] == 0) {
      R[vecin] = n;
      L[n] = vecin;
      return 1;
    }
  }
  for (i = 0; i < G[n].size(); i++) {
    int vecin = G[n][i];
    if (pairup(R[vecin]) == 1) {
      R[vecin] = n;
      L[n] = vecin;
      return 1;
    }
  }
  return 0;
}
void Matching() {
  int i, cuplaj = 0;
  bool change = 1;
  while (change == 1) {
    change = 0;
    memset(Use, 0, sizeof(Use));
    for (i = 1; i <= cntH; i++)
      if (L[i] == 0) change |= pairup(i);
  }
}
void DFS(int node) {
  UseL[node] = 1;
  for (int i = 0; i < G[node].size(); i++) {
    int neighb = G[node][i];
    UseR[neighb] = 1;
    if (R[neighb] != 0 && UseL[R[neighb]] == 0) DFS(R[neighb]);
  }
}
void printH(int horiz) {
  cout << HorizL[horiz].x1 << " " << HorizL[horiz].y << " " << HorizL[horiz].x2
       << " " << HorizL[horiz].y << "\n";
}
void printV(int vert) {
  cout << VertL[vert].y << " " << VertL[vert].x1 << " " << VertL[vert].y << " "
       << VertL[vert].x2 << "\n";
}
void printHoriz() {
  int nb = 0;
  int currl = HorizL[1].y;
  pair<int, int> res = make_pair(HorizL[1].x1, HorizL[1].x1);
  vector<Line> Sol;
  for (int i = 1; i <= cntH; i++) {
    if (UseL[i] == 0) {
      if (currl != 0) Sol.push_back({res.first, res.second, currl});
      if (currl != HorizL[i].y)
        Sol.push_back({HorizL[i].x1, HorizL[i].x1, HorizL[i].y});
      res = make_pair(HorizL[i].x2, HorizL[i].x2), currl = HorizL[i].y;
      continue;
    }
    if (res.second == HorizL[i].x1 && currl == HorizL[i].y)
      res.second = HorizL[i].x2;
    else {
      if (currl != 0) Sol.push_back({res.first, res.second, currl});
      res = make_pair(HorizL[i].x1, HorizL[i].x2), currl = HorizL[i].y;
    }
  }
  if (currl != 0) Sol.push_back({res.first, res.second, currl});
  cout << Sol.size() << "\n";
  for (int i = 0; i < Sol.size(); i++)
    cout << Sol[i].x1 << " " << Sol[i].y << " " << Sol[i].x2 << " " << Sol[i].y
         << "\n";
}
void printVert() {
  int currl = VertL[1].y;
  pair<int, int> res = make_pair(VertL[1].x1, VertL[1].x1);
  vector<Line> Sol;
  for (int i = 1; i <= cntV; i++) {
    if (UseR[i] == 1) {
      if (currl != 0) Sol.push_back({res.first, res.second, currl});
      if (currl != VertL[i].y)
        Sol.push_back({VertL[i].x1, VertL[i].x1, VertL[i].y});
      res = make_pair(VertL[i].x2, VertL[i].x2), currl = VertL[i].y;
      continue;
    }
    if (res.second == VertL[i].x1 && currl == VertL[i].y)
      res.second = VertL[i].x2;
    else {
      if (currl != 0) Sol.push_back({res.first, res.second, currl});
      res = make_pair(VertL[i].x1, VertL[i].x2), currl = VertL[i].y;
    }
  }
  if (currl != 0) Sol.push_back({res.first, res.second, currl});
  cout << Sol.size() << "\n";
  for (int i = 0; i < Sol.size(); i++)
    cout << Sol[i].y << " " << Sol[i].x1 << " " << Sol[i].y << " " << Sol[i].x2
         << "\n";
}
void MVC() {
  for (int i = 1; i <= cntH; i++)
    if (L[i] == 0) DFS(i);
  printHoriz();
  printVert();
}
int main() {
  Read();
  buildHorizLines();
  buildVertLines();
  buildGraph();
  Matching();
  MVC();
  return 0;
}