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;
template <typename T1, typename T2>
string print_iterable(T1 begin_iter, T2 end_iter, int counter) {
  bool done_something = false;
  stringstream res;
  res << "[";
  for (; begin_iter != end_iter and counter; ++begin_iter) {
    done_something = true;
    counter--;
    res << *begin_iter << ", ";
  }
  string str = res.str();
  if (done_something) {
    str.pop_back();
    str.pop_back();
  }
  str += "]";
  return str;
}
vector<int> SortIndex(int size, std::function<bool(int, int)> compare) {
  vector<int> ord(size);
  for (int i = 0; i < size; i++) ord[i] = i;
  sort(ord.begin(), ord.end(), compare);
  return ord;
}
template <typename T>
bool MinPlace(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool MaxPlace(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename Container>
int SZ(const Container& S) {
  return S.size();
}
template <typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T>& p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}
template <typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  for (int i = 0; i < (int)v.size(); i++) {
    out << v[i];
    if (i != (int)v.size() - 1) out << ", ";
  }
  out << "]";
  return out;
}
using namespace std;
vector<bool> left_doneX;
vector<bool> right_doneX;
class MaximumMatching {
 public:
  const static int NOT_MATCHED = -1;
  MaximumMatching(int left_num, int right_num, const vector<vector<int>>& edges)
      : left_num(left_num),
        right_num(right_num),
        edges(edges),
        computed_matching(false),
        matching_size(0),
        left2right(left_num, NOT_MATCHED),
        right2left(right_num, NOT_MATCHED) {}
  int GetSize() {
    ComputeMaximumMatching();
    return matching_size;
  }
  vector<int> GetMatching() {
    ComputeMaximumMatching();
    return left2right;
  }
  int left_num;
  int right_num;
  const vector<vector<int>>& edges;
  bool computed_matching;
  int matching_size;
  vector<int> left2right;
  vector<int> right2left;
  bool FindAugmentingPath(int v, vector<bool>& left_done,
                          vector<bool>& right_done) {
    if (left_done[v]) return false;
    left_done[v] = true;
    for (int a : edges[v]) {
      if (right_done[a] or left2right[v] == a) continue;
      right_done[a] = true;
      if (right2left[a] == NOT_MATCHED ||
          FindAugmentingPath(right2left[a], left_done, right_done)) {
        right2left[a] = v;
        left2right[v] = a;
        return true;
      }
    }
    return false;
  }
  void ComputeMaximumMatching() {
    if (computed_matching) return;
    left_doneX.resize(left_num, false);
    right_doneX.resize(right_num, false);
    bool matching_augmented = true;
    while (matching_augmented) {
      matching_augmented = false;
      fill(left_doneX.begin(), left_doneX.end(), false);
      fill(right_doneX.begin(), right_doneX.end(), false);
      for (int v = 0; v < left_num; v++) {
        if (left2right[v] == NOT_MATCHED) {
          bool updated = FindAugmentingPath(v, left_doneX, right_doneX);
          matching_augmented |= updated;
          matching_size += updated;
        }
      }
    }
    computed_matching = true;
  }
};
const int MaximumMatching::NOT_MATCHED;
const int MAXN = -1;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<pair<int, int>> P(N);
  map<int, map<int, int>> row, col;
  for (int i = 0; i < N; i++) {
    cin >> P[i].first >> P[i].second;
    row[P[i].second][P[i].first] = i;
    col[P[i].first][P[i].second] = i;
  }
  vector<pair<int, int>> lseg, rseg;
  for (auto& pp : row) {
    auto& mp = pp.second;
    vector<int> vec;
    for (auto pp2 : mp) vec.push_back(pp2.second);
    for (int i = 0; i < (int)vec.size() - 1; i++)
      lseg.push_back({vec[i], vec[i + 1]});
  }
  for (auto& pp : col) {
    auto& mp = pp.second;
    vector<int> vec;
    for (auto pp2 : mp) vec.push_back(pp2.second);
    for (int i = 0; i < (int)vec.size() - 1; i++)
      rseg.push_back({vec[i], vec[i + 1]});
  }
  int L = lseg.size();
  int R = rseg.size();
  vector<vector<int>> aa(L);
  for (int i = 0; i < L; i++) {
    for (int j = 0; j < R; j++) {
      if (P[lseg[i].first].first < P[rseg[j].first].first and
          P[rseg[j].first].first < P[lseg[i].second].first and
          P[rseg[j].first].second < P[lseg[i].first].second and
          P[lseg[i].first].second < P[rseg[j].second].second) {
        aa[i].push_back(j);
      }
    }
  }
  MaximumMatching mm(L, R, aa);
  mm.GetSize();
  vector<bool> hor_nostart(N), ver_nostart(N);
  for (int i = 0; i < L; i++) {
    if (left_doneX[i]) {
      hor_nostart[lseg[i].second] = true;
    }
  }
  for (int i = 0; i < R; i++) {
    if (!right_doneX[i]) {
      ver_nostart[rseg[i].second] = true;
    }
  }
  vector<pair<int, int>> ansh, ansv;
  for (auto& pp : row) {
    auto& mp = pp.second;
    vector<int> vec;
    for (auto pp2 : mp) vec.push_back(pp2.second);
    int curr = -1;
    for (int i = 0; i < (int)vec.size(); i++) {
      if (!hor_nostart[vec[i]]) {
        if (curr != -1) ansh.push_back({curr, vec[i - 1]});
        curr = vec[i];
      }
    }
    ansh.push_back({curr, vec.back()});
  }
  for (auto& pp : col) {
    auto& mp = pp.second;
    vector<int> vec;
    for (auto pp2 : mp) vec.push_back(pp2.second);
    int curr = -1;
    for (int i = 0; i < (int)vec.size(); i++) {
      if (!ver_nostart[vec[i]]) {
        if (curr != -1) ansv.push_back({curr, vec[i - 1]});
        curr = vec[i];
      }
    }
    ansv.push_back({curr, vec.back()});
  }
  cout << ansh.size() << "\n";
  for (auto pp : ansh) {
    cout << P[pp.first].first << " " << P[pp.first].second << " "
         << P[pp.second].first << " " << P[pp.second].second << "\n";
  }
  cout << ansv.size() << "\n";
  for (auto pp : ansv) {
    cout << P[pp.first].first << " " << P[pp.first].second << " "
         << P[pp.second].first << " " << P[pp.second].second << "\n";
  }
}