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;
int x[1010], y[1010];
set<int> sX, sY;
unordered_map<int, int> mX, mY;
int mrX[1010], mrY[1010];
vector<int> gx[1010];
vector<int> gy[1010];
vector<pair<int, pair<int, int> > > vh, vv;
int N, M;
vector<int> gr[1010];
vector<int> gr1[1010];
bool seen[1010];
int m[1010], m1[1010];
int dfs(int u) {
  if (u < 0) return 1;
  if (seen[u]) return 0;
  seen[u] = true;
  for (size_t i = 0, sz = gr[u].size(); i < sz; i++) {
    if (dfs(m1[gr[u][i]])) {
      m[u] = gr[u][i];
      m1[gr[u][i]] = u;
      return 1;
    }
  }
  return 0;
}
int dfsExp(int u) {
  for (int i = 0; i < N; i++) seen[i] = false;
  return dfs(u);
}
int bipMatch() {
  for (int i = 0; i < N; i++) m[i] = -1;
  for (int i = 0; i < M; i++) m1[i] = -1;
  int aug, ans = 0;
  do {
    aug = 0;
    bool first = true;
    for (int i = 0; i < N; i++)
      if (m[i] < 0) {
        if (first)
          aug += dfsExp(i);
        else
          aug += dfs(i);
        first = false;
      }
    ans += aug;
  } while (aug);
  return ans;
}
int mark[1010][2];
int cnt[1010][2];
void dfs1(int u, int flag) {
  mark[u][flag] = 1;
  if (flag == 1) {
    if (m1[u] != -1 && !mark[m1[u]][flag ^ 1]) dfs1(m1[u], flag ^ 1);
  } else {
    for (auto &v : gr[u])
      if (!mark[v][flag ^ 1]) dfs1(v, flag ^ 1);
  }
}
bool cmp(pair<pair<int, int>, int> A, pair<pair<int, int>, int> B) {
  if (A.second < B.second) return true;
  if (A.second > B.second) return false;
  return A.first < B.first;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<pair<pair<int, int>, pair<int, int> > > sol1, sol2;
  vector<pair<pair<int, int>, int> > ans1, ans2;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    sX.insert(x[i]);
    sY.insert(y[i]);
  }
  int k = 1;
  for (auto &u : sX) mX[u] = k, mrX[k++] = u;
  k = 1;
  for (auto &u : sY) mY[u] = k, mrY[k++] = u;
  for (int i = 0; i < n; i++) {
    x[i] = mX[x[i]];
    y[i] = mY[y[i]];
    ans1.push_back({{x[i], x[i]}, y[i]});
    ans2.push_back({{y[i], y[i]}, x[i]});
    gx[x[i]].push_back(y[i]);
    gy[y[i]].push_back(x[i]);
  }
  for (int i = 0; i < 1010; i++) {
    if (gx[i].size() <= 1) continue;
    sort(gx[i].begin(), gx[i].end());
    for (int j = 0; j < gx[i].size() - 1; j++)
      vv.push_back({i, {gx[i][j], gx[i][j + 1]}});
  }
  for (int i = 0; i < 1010; i++) {
    if (gy[i].size() <= 1) continue;
    sort(gy[i].begin(), gy[i].end());
    for (int j = 0; j < gy[i].size() - 1; j++)
      vh.push_back({i, {gy[i][j], gy[i][j + 1]}});
  }
  N = vh.size();
  M = vv.size();
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < M; j++) {
      if (vh[i].first < vv[j].second.second &&
          vh[i].first > vv[j].second.first &&
          vv[j].first < vh[i].second.second && vv[j].first > vh[i].second.first)
        gr[i].push_back(j), cnt[i][0]++, cnt[j][1]++;
    }
  }
  bipMatch();
  for (int i = 0; i < N; i++)
    if (m[i] == -1 && cnt[i][0]) dfs1(i, 0);
  for (int i = 0; i < N; i++) {
    if (mark[i][0] || !cnt[i][0])
      ans1.push_back({{vh[i].second.first, vh[i].second.second}, vh[i].first});
  }
  for (int j = 0; j < M; j++) {
    if (!mark[j][1] || !cnt[j][1])
      ans2.push_back({{vv[j].second.first, vv[j].second.second}, vv[j].first});
  }
  sort(ans1.begin(), ans1.end(), cmp);
  sort(ans2.begin(), ans2.end(), cmp);
  for (int i = 0; i < ans1.size(); i++) {
    int j = i;
    while (j + 1 < ans1.size() &&
           ans1[j + 1].first.first == ans1[j].first.second &&
           ans1[j + 1].second == ans1[i].second)
      j++;
    sol1.push_back({{ans1[i].first.first, ans1[i].second},
                    {ans1[j].first.second, ans1[i].second}});
    i = j;
  }
  for (int i = 0; i < ans2.size(); i++) {
    int j = i;
    while (j + 1 < ans2.size() &&
           ans2[j + 1].first.first == ans2[j].first.second &&
           ans2[j + 1].second == ans2[i].second)
      j++;
    sol2.push_back({{ans2[i].second, ans2[i].first.first},
                    {ans2[i].second, ans2[j].first.second}});
    i = j;
  }
  cout << sol1.size() << "\n";
  for (auto &u : sol1) {
    cout << mrX[u.first.first] << " " << mrY[u.first.second] << " "
         << mrX[u.second.first] << " " << mrY[u.second.second] << "\n";
  }
  cout << sol2.size() << "\n";
  for (auto &u : sol2) {
    cout << mrX[u.first.first] << " " << mrY[u.first.second] << " "
         << mrX[u.second.first] << " " << mrY[u.second.second] << "\n";
  }
  return 0;
}