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>
#pragma GCC diagnostic ignored "-Wunused-result"
#pragma GCC diagnostic ignored "-Wunused-function"
using namespace std;
namespace {
namespace shik {
template <class T>
void _R(T &x) {
  cin >> x;
}
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%" SCNd64, &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template <class T, class... U>
void R(T &head, U &...tail) {
  _R(head);
  R(tail...);
}
template <class T>
void _W(const T &x) {
  cout << x;
}
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%" PRId64, x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template <class T>
void _W(const vector<T> &x) {
  for (auto i = x.begin(); i != x.end(); _W(*i++))
    if (i != x.cbegin()) putchar(' ');
}
void W() {}
template <class T, class... U>
void W(const T &head, const U &...tail) {
  _W(head);
  putchar(sizeof...(tail) ? ' ' : '\n');
  W(tail...);
}
template <class T, class F = less<T>>
void sort_uniq(vector<T> &v, F f = F()) {
  sort(begin(v), end(v), f);
  v.resize(unique(begin(v), end(v)) - begin(v));
}
template <class T>
inline T bit(T x, int i) {
  return (x >> i) & 1;
}
template <class T>
inline bool chkmax(T &a, const T &b) {
  return b > a ? a = b, true : false;
}
template <class T>
inline bool chkmin(T &a, const T &b) {
  return b < a ? a = b, true : false;
}
template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
struct Maxflow {
  struct E {
    int to, cap, rev, rcap, ucap;
    E() {}
    E(int _to, int _cap, int _rev)
        : to(_to), cap(_cap), rev(_rev), rcap(_cap) {}
  };
  int n;
  vector<vector<E>> e;
  vector<vector<E>::iterator> cur;
  vector<int> dis;
  void init(int _n) {
    n = _n;
    e.resize(n);
    cur.resize(n);
    dis.resize(n);
    for (int i = 0; i < int(n); i++) e[i].clear();
  }
  void add(int a, int b, int c) {
    if (a == b) return;
    e[a].push_back(E(b, c, e[b].size()));
    e[b].push_back(E(a, 0, e[a].size() - 1));
  }
  bool bfs() {
    fill(dis.begin(), dis.end(), -1);
    queue<int> q;
    dis[0] = 0;
    q.push(0);
    while (!q.empty() && dis[n - 1] == -1) {
      int p = q.front();
      q.pop();
      for (__typeof((e[p]).begin()) it = (e[p]).begin(); it != (e[p]).end();
           it++) {
        if (it->cap == 0 || dis[it->to] != -1) continue;
        dis[it->to] = dis[p] + 1;
        q.push(it->to);
      }
    }
    return dis[n - 1] != -1;
  }
  int64_t go(int p, int64_t c) {
    if (p == n - 1) return c;
    int64_t ret = 0;
    for (; cur[p] != e[p].end(); cur[p]++) {
      if (cur[p]->cap == 0 || dis[cur[p]->to] != dis[p] + 1) continue;
      int64_t now = go(cur[p]->to, min((int64_t)cur[p]->cap, c - ret));
      ret += now;
      cur[p]->cap -= now;
      e[cur[p]->to][cur[p]->rev].cap += now;
      if (ret == c) break;
    }
    if (ret == 0) dis[p] = -1;
    return ret;
  }
  int64_t maxflow() {
    int64_t ret = 0;
    while (bfs()) {
      for (int i = 0; i < int(n); i++) cur[i] = e[i].begin();
      ret += go(0, 1LL << 60);
    }
    return ret;
  }
  bool _addPath(int wh, vector<vector<int>> &ans) {
    if (wh == n - 1) {
      ans.push_back(vector<int>());
      ans.back().push_back(wh);
      return true;
    }
    for (__typeof((e[wh]).begin()) it = (e[wh]).begin(); it != (e[wh]).end();
         it++)
      if (it->ucap > 0 && _addPath(it->to, ans)) {
        it->ucap--;
        ans.back().push_back(wh);
        return true;
      }
    return false;
  }
  vector<vector<int>> getPath() {
    vector<vector<int>> ans;
    for (__typeof((e).begin()) it = (e).begin(); it != (e).end(); it++)
      for (__typeof((*it).begin()) jt = (*it).begin(); jt != (*it).end(); jt++)
        jt->ucap = max(0, jt->rcap - jt->cap);
    while (_addPath(0, ans)) reverse(ans.back().begin(), ans.back().end());
    return ans;
  }
} flow;
struct DJS {
  vector<int> fa, sz;
  DJS() {}
  DJS(int n) { init(n); }
  void init(int n) {
    n++;
    fa.resize(n);
    sz.resize(n);
    for (int i = 0; i < n; i++) {
      fa[i] = i;
      sz[i] = 1;
    }
  }
  int f(int x) {
    while (x != fa[x]) x = fa[x] = fa[fa[x]];
    return x;
  }
  void u(int a, int b) {
    a = f(a);
    b = f(b);
    if (a == b) return;
    if (sz[a] > sz[b]) swap(a, b);
    fa[a] = b;
    sz[b] += sz[a];
  }
  int size(int x) { return sz[f(x)]; }
  bool is_root(int x) { return x == fa[x]; }
  bool same(int a, int b) { return f(a) == f(b); }
};
bool jiao(int x, int yl, int yr, int y, int xl, int xr) {
  if (x < xl || x > xr) return 0;
  if (y < yl || y > yr) return 0;
  return 1;
}
const int N = 1010;
int n, x[N], y[N], px[N], py[N];
bool ban[N][N];
vector<int> ex[N], ey[N];
bool ma[N], mb[N];
set<pair<int, int>> st;
vector<int> gx[N], gy[N];
void main() {
  R(n);
  for (int i = (1); i <= int(n); i++) R(x[i], y[i]);
  for (int i = (1); i <= int(n); i++)
    for (int j = (1); j <= int(n); j++)
      if (x[i] == x[j] && y[j] < y[i] && (px[i] == 0 || y[j] > y[px[i]]))
        px[i] = j;
  for (int i = (1); i <= int(n); i++)
    for (int j = (1); j <= int(n); j++)
      if (y[i] == y[j] && x[j] < x[i] && (py[i] == 0 || x[j] > x[py[i]]))
        py[i] = j;
  for (int i = (1); i <= int(n); i++) st.insert({x[i], y[i]});
  int sink = 2 * n + 1;
  flow.init(sink + 1);
  for (int i = (1); i <= int(n); i++) flow.add(0, i, 1);
  for (int i = (1); i <= int(n); i++) flow.add(n + i, sink, 1);
  for (int i = (1); i <= int(n); i++)
    for (int j = (1); j <= int(n); j++)
      if (i != j) {
        if (!px[i] || !py[j]) continue;
        if (!jiao(x[i], y[px[i]], y[i], y[j], x[py[j]], x[j])) continue;
        if (st.count({x[i], y[j]})) continue;
        ban[i][j] = 1;
        ex[i].push_back(j);
        ey[j].push_back(i);
        flow.add(i, n + j, 1);
      }
  int f = flow.maxflow();
  int cnt = 0;
  for (int i = (1); i <= int(n); i++) cnt += !!px[i] + !!py[i];
  cnt -= f;
  int ans = 2 * n - cnt;
  ;
  auto ps = flow.getPath();
  for (auto p : ps) {
    assert(((int)(p).size()) == 4);
    int a = p[1], b = p[2] - n;
    ma[a] = mb[b] = 1;
  }
  set<int> sa, sb, ta, tb;
  for (int i = (1); i <= int(n); i++)
    if (!ma[i] && px[i]) sa.insert(i);
  for (int i = (1); i <= int(n); i++)
    if (!mb[i] && py[i]) sb.insert(i);
  for (int k = (1); k <= int(n); k++) {
    int z = ((int)(sa).size()) + ((int)(sb).size()) + ((int)(ta).size()) +
            ((int)(tb).size());
    for (int i = (1); i <= int(n); i++)
      if (sa.count(i))
        for (int j : ex[i]) tb.insert(j);
    for (int i = (1); i <= int(n); i++)
      if (sb.count(i))
        for (int j : ey[i]) ta.insert(j);
    for (auto p : ps) {
      int a = p[1], b = p[2] - n;
      if (ta.count(a)) sb.insert(b);
      if (tb.count(b)) sa.insert(a);
    }
    if (z == ((int)(sa).size()) + ((int)(sb).size()) + ((int)(ta).size()) +
                 ((int)(tb).size()))
      break;
  }
  for (int i = (1); i <= int(n); i++)
    if (px[i] && !sa.count(i) && !ta.count(i)) sa.insert(i);
  ;
  DJS dx(n), dy(n);
  for (int i : sa) dx.u(px[i], i);
  for (int i : sb) dy.u(py[i], i);
  for (int i = (1); i <= int(n); i++) gx[dx.f(i)].push_back(y[i]);
  for (int i = (1); i <= int(n); i++) gy[dy.f(i)].push_back(x[i]);
  vector<array<int, 4>> tx, ty;
  for (int i = (1); i <= int(n); i++)
    if (!gx[i].empty()) {
      int mi = *min_element(begin(gx[i]), end(gx[i]));
      int mx = *max_element(begin(gx[i]), end(gx[i]));
      tx.push_back({x[i], mi, x[i], mx});
    }
  for (int i = (1); i <= int(n); i++)
    if (!gy[i].empty()) {
      int mi = *min_element(begin(gy[i]), end(gy[i]));
      int mx = *max_element(begin(gy[i]), end(gy[i]));
      ty.push_back({mi, y[i], mx, y[i]});
    }
  assert(((int)(tx).size()) + ((int)(ty).size()) == ans);
  W(((int)(ty).size()));
  for (auto t : ty) W(vector<int>(begin(t), end(t)));
  W(((int)(tx).size()));
  for (auto t : tx) W(vector<int>(begin(t), end(t)));
}
}  // namespace shik
}  // namespace
int main() {
  shik::main();
  return 0;
}