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 inf = 1e9 + 9;
const long long int MOD = 1e9 + 696969;
const long long INF = 1e18 + 3;
const int maxn = 2010;
int n, m;
const int W = 2010;
pair<int, int> pox[maxn], poy[maxn];
int skoj[W];
vector<int> v[W];
bool odw[W], chosen[W];
bool dfs(int x) {
  if (odw[x]) return false;
  odw[x] = 1;
  for (auto u : v[x])
    if (skoj[u] == -1 || dfs(skoj[u])) {
      skoj[u] = x;
      skoj[x] = u;
      return true;
    }
  return false;
}
queue<int> q;
void bfs() {
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto u : v[x]) {
      assert(skoj[u] != -1);
      if (!chosen[skoj[u]]) {
        chosen[skoj[u]] = 1;
        q.push(skoj[u]);
      }
    }
  }
}
int DL = 0;
int INVERT[2010], KT[2010];
inline long long int det(pair<long long int, long long int> a,
                         pair<long long int, long long int> b) {
  return a.first * b.second - a.second * b.first;
}
inline long long int area(pair<long long int, long long int> a,
                          pair<long long int, long long int> b,
                          pair<long long int, long long int> c) {
  return det(a, b) + det(b, c) + det(c, a);
}
inline bool isLeft(pair<long long int, long long int> a,
                   pair<long long int, long long int> b,
                   pair<long long int, long long int> c) {
  return (area(a, b, c) > 0);
}
inline long long int sqr(long long int x) { return x * x; }
inline long long int dist(pair<long long int, long long int> a,
                          pair<long long int, long long int> b) {
  return sqr(a.first - b.first) + sqr(a.second - b.second);
}
inline bool Inside(pair<long long int, long long int> a,
                   pair<long long int, long long int> b,
                   pair<long long int, long long int> c) {
  if (area(a, b, c) != 0) return 0;
  long long int dbc = dist(b, c), dac = dist(a, c), dab = dist(a, b);
  if (dbc <= dab && dac <= dab) return 1;
  return 0;
}
inline bool Intersect(pair<long long int, long long int> a,
                      pair<long long int, long long int> b,
                      pair<long long int, long long int> c,
                      pair<long long int, long long int> d) {
  if (Inside(a, b, c)) return 0;
  if (Inside(a, b, d)) return 0;
  if (Inside(c, d, a)) return 0;
  if (Inside(c, d, b)) return 0;
  long long int A1 = area(a, b, c), A2 = area(a, b, d);
  long long int B1 = area(c, d, a), B2 = area(c, d, b);
  if (A1 > 0 && A2 > 0) return 0;
  if (A1 < 0 && A2 < 0) return 0;
  if (B1 > 0 && B2 > 0) return 0;
  if (B1 < 0 && B2 < 0) return 0;
  if (A1 == 0 || A2 == 0 || B1 == 0 || B2 == 0) return 0;
  return 1;
}
vector<pair<pair<long long int, long long int>, pair<int, long long int> > >
    odc1, odc2;
bool gold[maxn];
int main() {
  ios_base::sync_with_stdio(false);
  int t = 1;
  while (t--) {
    cin >> n;
    for (int i = (1); i <= (n); ++i) cin >> pox[i].first >> pox[i].second;
    sort(pox + 1, pox + n + 1);
    for (int i = (1); i <= (n); ++i) {
      poy[i] = pox[i];
      swap(poy[i].first, poy[i].second);
    }
    sort(poy + 1, poy + n + 1);
    for (int i = (1); i <= (n); ++i) swap(poy[i].first, poy[i].second);
    for (int i = (2); i <= (n); ++i)
      if (pox[i].first == pox[i - 1].first) {
        KT[i] = ++DL;
        INVERT[DL] = i;
      }
    for (int i = (2); i <= (n); ++i)
      if (poy[i].second == poy[i - 1].second) {
        KT[i + n] = ++DL;
        INVERT[DL] = i + n;
      }
    for (int i = (2); i <= (n); ++i)
      for (int j = (2); j <= (n); ++j)
        if (pox[i].first == pox[i - 1].first &&
            poy[j].second == poy[j - 1].second) {
          pair<pair<long long int, long long int>, pair<int, long long int> >
              jed = make_pair(make_pair(pox[i - 1].first, pox[i - 1].second),
                              make_pair(pox[i].first, pox[i].second));
          pair<pair<long long int, long long int>, pair<int, long long int> >
              dwa = make_pair(make_pair(poy[j - 1].first, poy[j - 1].second),
                              make_pair(poy[j].first, poy[j].second));
          if (Intersect(jed.first, jed.second, dwa.first, dwa.second)) {
            v[KT[i]].push_back(KT[j + n]);
            v[KT[j + n]].push_back(KT[i]);
          }
        }
    for (int i = (1); i <= (DL); ++i) skoj[i] = -1;
    int ult_result = 2 * n;
    bool ist = 1;
    int sz = 0;
    while (ist) {
      ist = false;
      for (int i = (1); i <= (DL); ++i) odw[i] = false;
      for (int i = (1); i <= (DL); ++i)
        if (!odw[i] && skoj[i] == -1 && dfs(i)) ist = true, ++sz;
    }
    while (!q.empty()) q.pop();
    int cnt = 0;
    for (int i = (1); i <= (DL); ++i)
      if (skoj[i] == -1) ++cnt, q.push(i), chosen[i] = 1;
    bfs();
    for (int i = (1); i <= (DL); ++i)
      if (!chosen[i] && !chosen[skoj[i]]) chosen[i] = 1;
    for (int i = (1); i <= (DL); ++i) gold[INVERT[i]] = chosen[i];
    for (int i = (1); i <= (n); ++i)
      if (!gold[i])
        odc1.push_back(make_pair(pox[i], pox[i]));
      else {
        int sajs = (int)odc1.size() - 1;
        odc1[sajs].second = pox[i];
      }
    for (int i = (1); i <= (n); ++i)
      if (!gold[i + n])
        odc2.push_back(make_pair(poy[i], poy[i]));
      else {
        int sajs = (int)odc2.size() - 1;
        odc2[sajs].second = poy[i];
      }
    swap(odc1, odc2);
    cout << (int)odc1.size() << "\n";
    for (auto u : odc1)
      cout << u.first.first << ' ' << u.first.second << ' ' << u.second.first
           << ' ' << u.second.second << "\n";
    cout << (int)odc2.size() << "\n";
    for (auto u : odc2)
      cout << u.first.first << ' ' << u.first.second << ' ' << u.second.first
           << ' ' << u.second.second << "\n";
  }
}