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 optimize("Ofast")
#pragma GCC tet( \
    "sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const int MOD = 1000000007;
const int UNDEF = -1;
const int INF = 1 << 30;
template <typename T>
inline bool chkmax(T &aa, T bb) {
  return aa < bb ? aa = bb, true : false;
}
template <typename T>
inline bool chkmin(T &aa, T bb) {
  return aa > bb ? aa = bb, true : false;
}
template <typename T>
class Dinic {
 public:
  static const T MAXN = 2004;
  struct edge {
    T a, b, cap, flow;
  };
  T dinic_numnodes, dinic_src, dinic_dest, d[MAXN], ptr[MAXN], q[MAXN];
  vector<edge> dinic_edge;
  vector<T> dinic_graph[MAXN];
  void add_edge(T a, T b, T cap) {
    edge e1 = {a, b, cap, 0};
    edge e2 = {b, a, 0, 0};
    dinic_graph[a].push_back((T)dinic_edge.size());
    dinic_edge.push_back(e1);
    dinic_graph[b].push_back((T)dinic_edge.size());
    dinic_edge.push_back(e2);
  }
  bool dinic_bfs() {
    int qh = 0, qt = 0;
    q[qt++] = dinic_src;
    memset(d, -1, dinic_numnodes * sizeof d[0]);
    d[dinic_src] = 0;
    while (qh < qt && d[dinic_dest] == -1) {
      T v = q[qh++];
      for (size_t i = 0; i < dinic_graph[v].size(); ++i) {
        T id = dinic_graph[v][i], to = dinic_edge[id].b;
        if (d[to] == -1 && dinic_edge[id].flow < dinic_edge[id].cap) {
          q[qt++] = to;
          d[to] = d[v] + 1;
        }
      }
    }
    return d[dinic_dest] != -1;
  }
  T dinic_dfs(T v, T flow) {
    if (!flow) return 0;
    if (v == dinic_dest) return flow;
    for (; ptr[v] < (T)dinic_graph[v].size(); ++ptr[v]) {
      T id = dinic_graph[v][ptr[v]], to = dinic_edge[id].b;
      if (d[to] != d[v] + 1) continue;
      T pushed =
          dinic_dfs(to, min(flow, dinic_edge[id].cap - dinic_edge[id].flow));
      if (pushed) {
        dinic_edge[id].flow += pushed;
        dinic_edge[id ^ 1].flow -= pushed;
        return pushed;
      }
    }
    return 0;
  }
  T flow(T src, T dest, T numnodes) {
    if (src == dest) return INF;
    dinic_src = src;
    dinic_dest = dest;
    dinic_numnodes = numnodes;
    T flow = 0;
    for (;;) {
      if (!dinic_bfs()) break;
      memset(ptr, 0, dinic_numnodes * sizeof ptr[0]);
      while (T pushed = dinic_dfs(dinic_src, INF)) flow += pushed;
    }
    return flow;
  }
  void dinic_clear(T numnodes) {
    dinic_edge.clear();
    for (int v = 0; v < numnodes; v++) dinic_graph[v].clear();
  }
  bitset<MAXN> inS;
  void _getCut(int x) {
    inS[x] = true;
    for (auto &ei : dinic_graph[x]) {
      auto &e = dinic_edge[ei];
      if (e.cap > e.flow) {
        int y = e.b;
        if (!inS[y]) {
          _getCut(y);
        }
      }
    }
  }
  void getCut() {
    inS.reset();
    _getCut(dinic_src);
  }
};
template <typename T>
int bins(const vector<T> &v, const T key) {
  int imin = 0, imax = v.size();
  while (imin < imax) {
    int imid = (imin + imax) >> 1;
    if (v[imid] < key)
      imin = imid + 1;
    else
      imax = imid;
  }
  return imin;
}
int gid = 2;
int SRC = 0, DEST = 1;
map<pair<int, int>, int> h[2];
Dinic<int> dinic;
vector<pair<int, pair<int, int> > > g2t;
int getid(int t, pair<int, int> p) {
  auto it = h[t].find(p);
  if (it != h[t].end()) return it->second;
  h[t][p] = gid;
  g2t.push_back(make_pair(t, p));
  if (t == 0)
    dinic.add_edge(SRC, gid, 1);
  else
    dinic.add_edge(gid, DEST, 1);
  return gid++;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  g2t.resize(2);
  int n;
  cin >> n;
  map<int, vector<int> > x2y[2];
  set<pair<int, int> > s;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x2y[0][x].push_back(y);
    x2y[1][y].push_back(x);
    s.insert(make_pair(x, y));
  }
  for (int t = 0; t < 2; t++)
    for (auto &a : x2y[t]) sort(a.second.begin(), a.second.end());
  for (int t = 0; t < 2; t++) {
    for (auto &a : x2y[t]) {
      int py = -1;
      for (auto &ny : a.second) {
        if (py != -1) getid(t, make_pair(a.first, py));
        py = ny;
      }
    }
  }
  {
    int t = 0;
    for (auto &a : x2y[t]) {
      int x = a.first;
      int py = -1;
      auto yit = x2y[t ^ 1].begin();
      for (auto &ny : a.second) {
        if (py != -1) {
          while (yit != x2y[t ^ 1].end() && yit->first < py) ++yit;
          while (yit != x2y[t ^ 1].end() && yit->first <= ny) {
            int cix = bins(yit->second, x);
            for (int ix = max(0, cix - 3);
                 ix < min((int)yit->second.size() - 1, cix + 3); ix++) {
              int px = yit->second[ix];
              int nx = yit->second[ix + 1];
              int y = yit->first;
              if (px <= x && x <= nx && py <= y && y <= ny &&
                  s.find(make_pair(x, y)) == s.end()) {
                int id1 = getid(t, make_pair(x, py)),
                    id2 = getid(t ^ 1, make_pair(y, px));
                if (t == 1) swap(id1, id2);
                dinic.add_edge(id1, id2, 5000);
              }
            }
            ++yit;
          }
          if (yit != x2y[t ^ 1].begin()) --yit;
        }
        py = ny;
      }
    }
  }
  int flow = dinic.flow(SRC, DEST, gid);
  dinic.getCut();
  vector<pair<int, pair<int, int> > > vans[2];
  for (int t = 0; t < 2; t++) {
    for (auto &a : x2y[t]) {
      int x = a.first;
      int ly = -1;
      int py = -1;
      for (auto &ny : a.second) {
        if (ly == -1) ly = ny;
        if (py != -1) {
          int id = getid(t, make_pair(x, py));
          if ((t == 0) != (dinic.inS[id])) {
            vans[t].push_back(make_pair(x, make_pair(ly, py)));
            ly = ny;
          }
        }
        py = ny;
      }
      if (ly != -1) {
        vans[t].push_back(make_pair(x, make_pair(ly, py)));
      }
    }
  }
  printf("%d\n", (int)vans[1].size());
  for (auto &w : vans[1]) {
    printf("%d %d %d %d\n", w.second.first, w.first, w.second.second, w.first);
  }
  printf("%d\n", (int)vans[0].size());
  for (auto &w : vans[0]) {
    printf("%d %d %d %d\n", w.first, w.second.first, w.first, w.second.second);
  }
  int nume = gid - 2;
  int ans = 2 * n - nume + flow;
}