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 <class T>
void na(vector<T>& a, int n) {
  a = vector<T>(n);
  for (T& i : a) cin >> i;
}
template <class T>
void printVector(vector<T>& a) {
  for (T& i : a) cout << i << ' ';
  cout << '\n';
}
template <class T>
vector<T> shrink(vector<T>& first) {
  vector<T> vals = first;
  sort((vals).begin(), (vals).end());
  (vals).resize(unique((vals).begin(), (vals).end()) - (vals).begin());
  for (T& i : first)
    i = upper_bound((vals).begin(), (vals).end(), i) - vals.begin();
  return vals;
}
template <typename cap_type>
struct Dinic {
  static const int MAXV = 2222;
  static const cap_type oo = numeric_limits<cap_type>::max();
  using edge = tuple<int, int, cap_type, int>;
  int s, t, V, layer[MAXV], last[MAXV], last_0[MAXV];
  vector<edge> graph;
  Dinic(int N) : V(N) { fill(last, last + N + 1, -1); }
  void add_edge(int u, int v, cap_type cap = 1) {
    graph.emplace_back(u, v, cap, last[u]);
    last[u] = graph.size() - 1;
    graph.emplace_back(v, u, 0, last[v]);
    last[v] = graph.size() - 1;
  }
  bool bfs() {
    fill(layer, layer + V + 1, -1);
    layer[t] = 0;
    queue<int> q;
    q.push(t);
    while (!q.empty()) {
      int node = q.front();
      q.pop();
      for (int e = last[node]; e != -1; e = get<3>(graph[e])) {
        edge& din = graph[e ^ 1];
        if (get<2>(din) > 0 && layer[get<0>(din)] == -1) {
          layer[get<0>(din)] = layer[node] + 1;
          q.push(get<0>(din));
        }
      }
    }
    return layer[s] != -1;
  }
  cap_type dfs(int node, cap_type flow) {
    if (node == t) return flow;
    for (int e = last_0[node]; e != -1; e = get<3>(graph[e])) {
      edge& dout = graph[e];
      edge& din = graph[e ^ 1];
      last_0[node] = e;
      if (get<2>(dout) > 0 && layer[get<1>(dout)] + 1 == layer[get<0>(dout)]) {
        cap_type f = dfs(get<1>(dout), min(flow, get<2>(dout)));
        if (f > 0) {
          get<2>(dout) -= f;
          get<2>(din) += f;
          return f;
        }
      }
    }
    return 0;
  }
  cap_type get_mf(int src, int snk) {
    s = src, t = snk;
    cap_type totflow = 0, amt;
    while (bfs()) {
      for (int i = 0; i <= V; i++) last_0[i] = last[i];
      while ((amt = dfs(s, oo)) > 0) totflow += amt;
    }
    return totflow;
  }
};
struct seg {
  pair<int, int> st, ed;
  seg() {}
  seg(pair<int, int> a, pair<int, int> b) : st(a), ed(b) {}
  void print() {
    cerr << "[" << st.first << ", " << st.second << "] ->  [" << ed.first
         << ", " << ed.second << "]\n";
  }
};
bool intersects(seg v, seg h) {
  return h.st.first < v.st.first && v.st.first < h.ed.first &&
         v.st.second < h.st.second && h.st.second < v.ed.second;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0), cout.tie();
  int n;
  cin >> n;
  vector<int> xs, first(n), ys, second(n);
  for (int i = 0; i < n; ++i) cin >> first[i] >> second[i];
  xs = shrink(first);
  ys = shrink(second);
  vector<vector<int>> Xaxe(((int)(xs).size()) + 1),
      Yaxe(((int)(ys).size()) + 1);
  for (int i = 0; i < n; ++i) {
    Xaxe[first[i]].push_back(second[i]);
    Yaxe[second[i]].push_back(first[i]);
  }
  for (auto& i : Xaxe) sort((i).begin(), (i).end());
  for (auto& i : Yaxe) sort((i).begin(), (i).end());
  vector<seg> V, H;
  int cnt = 0;
  for (auto& i : Xaxe) {
    int last = -1;
    for (auto& j : i) {
      if (~last) V.emplace_back(make_pair(cnt, last), make_pair(cnt, j));
      last = j;
    }
    ++cnt;
  }
  cnt = 0;
  for (auto& i : Yaxe) {
    int last = -1;
    for (auto& j : i) {
      if (~last) H.emplace_back(make_pair(last, cnt), make_pair(j, cnt));
      last = j;
    }
    ++cnt;
  }
  Dinic<int> dinic(((int)(V).size()) + ((int)(H).size()) + 2);
  int s = 0, t = 1;
  for (int i = 0; i < ((int)(V).size()); ++i) {
    dinic.add_edge(s, i + 2);
    for (int j = 0; j < ((int)(H).size()); ++j)
      if (intersects(V[i], H[j]))
        dinic.add_edge(i + 2, ((int)(V).size()) + j + 2);
  }
  for (int j = 0; j < ((int)(H).size()); ++j)
    dinic.add_edge(((int)(V).size()) + j + 2, t);
  int mf = dinic.get_mf(s, t);
  cerr << "Total: " << mf + ((int)(xs).size()) + ((int)(ys).size()) << '\n';
  vector<bool> erasedV(((int)(V).size()), false);
  for (int i = 2; i < ((int)(V).size()) + 2; ++i) {
    if (dinic.layer[i] != -1) erasedV[i - 2] = true;
  }
  vector<bool> erasedH(((int)(H).size()), false);
  for (int i = ((int)(V).size()) + 2;
       i < ((int)(V).size()) + ((int)(H).size()) + 2; ++i) {
    if (dinic.layer[i] == -1) erasedH[i - (((int)(V).size()) + 2)] = true;
  }
  vector<seg> ansV, ansH;
  for (int i = 0, j; i < ((int)(V).size()); i = j) {
    j = i;
    if (erasedV[j]) {
      if (j == 0 || (erasedV[j - 1] && V[j - 1].st.first == V[j].st.first) ||
          V[j - 1].st.first != V[j].st.first)
        ansV.emplace_back(make_pair(V[j].st.first, V[j].st.second),
                          make_pair(V[j].st.first, V[j].st.second));
      if (j + 1 == ((int)(V).size()) || V[j + 1].st.first != V[j].st.first)
        ansV.emplace_back(make_pair(V[j].ed.first, V[j].ed.second),
                          make_pair(V[j].ed.first, V[j].ed.second));
      ++j;
      continue;
    }
    int first = V[i].st.first;
    int second = V[i].st.second;
    int ymax = V[i].ed.second;
    while (j < ((int)(V).size()) && !erasedV[j] && V[j].st.first == first) {
      ymax = V[j].ed.second;
      ++j;
    }
    ansV.emplace_back(make_pair(first, second), make_pair(first, ymax));
  }
  cnt = 0;
  for (auto& i : Xaxe) {
    if (((int)(i).size()) == 1)
      ansV.emplace_back(make_pair(cnt, i[0]), make_pair(cnt, i[0]));
    ++cnt;
  }
  for (int i = 0, j; i < ((int)(H).size()); i = j) {
    j = i;
    if (erasedH[j]) {
      if (j == 0 || (erasedH[j - 1] && H[j - 1].st.second == H[j].st.second) ||
          H[j - 1].st.second != H[j].st.second)
        ansH.emplace_back(make_pair(H[j].st.first, H[j].st.second),
                          make_pair(H[j].st.first, H[j].st.second));
      if (j + 1 == ((int)(H).size()) || H[j + 1].st.second != H[j].st.second)
        ansH.emplace_back(make_pair(H[j].ed.first, H[j].ed.second),
                          make_pair(H[j].ed.first, H[j].ed.second));
      ++j;
      continue;
    }
    int first = H[i].st.first;
    int second = H[i].st.second;
    int xmax = H[i].ed.first;
    while (j < ((int)(H).size()) && !erasedH[j] && H[j].st.second == second) {
      xmax = H[j].ed.first;
      ++j;
    }
    ansH.emplace_back(make_pair(first, second), make_pair(xmax, second));
  }
  cnt = 0;
  for (auto& i : Yaxe) {
    if (((int)(i).size()) == 1)
      ansH.emplace_back(make_pair(i[0], cnt), make_pair(i[0], cnt));
    ++cnt;
  }
  cout << ((int)(ansH).size()) << '\n';
  for (auto& i : ansH)
    cout << xs[i.st.first - 1] << ' ' << ys[i.st.second - 1] << ' '
         << xs[i.ed.first - 1] << ' ' << ys[i.ed.second - 1] << '\n';
  cout << ((int)(ansV).size()) << '\n';
  for (auto& i : ansV)
    cout << xs[i.st.first - 1] << ' ' << ys[i.st.second - 1] << ' '
         << xs[i.ed.first - 1] << ' ' << ys[i.ed.second - 1] << '\n';
  return 0;
}