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;
struct Maxflow {
  struct edge {
    int from, to;
    long long flow, capacity;
  };
  int s, t;
  vector<edge> edg;
  vector<int> g[3111];
  int dist[3111], visited[3111];
  int cur[3111];
  void init() {
    edg.clear();
    int i;
    for (i = 0; i < 3111; i++) {
      g[i].clear();
    }
  }
  void addedge(int from, int to, long long capacity) {
    edge e1 = edge{from, to, 0ll, capacity};
    edge e2 = edge{to, from, 0ll, 0ll};
    edg.push_back(e1), edg.push_back(e2);
    g[from].push_back((int)edg.size() - 2);
    g[to].push_back((int)edg.size() - 1);
  }
  bool bfs() {
    memset(visited, 0, sizeof(visited));
    memset(dist, 0, sizeof(dist));
    queue<int> q;
    q.push(s);
    visited[s] = 1;
    dist[s] = 0;
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      for (int i = 0; i < (int)g[v].size(); i++) {
        edge &e = edg[g[v][i]];
        int nxt = e.to;
        if (!visited[nxt] && e.capacity > e.flow) {
          dist[nxt] = dist[v] + 1;
          q.push(nxt);
          visited[nxt] = 1;
        }
      }
    }
    return visited[t];
  }
  long long dfs(int x, long long cp) {
    if (x == t || cp == 0) {
      return cp;
    }
    long long flow = 0, newflow;
    for (int &y = cur[x]; y < (int)g[x].size(); y++) {
      edge &e = edg[g[x][y]];
      if (dist[x] + 1 == dist[e.to]) {
        long long minn = min(cp, e.capacity - e.flow);
        newflow = dfs(e.to, minn);
        if (newflow > 0) {
          e.flow += newflow;
          edg[g[x][y] ^ 1].flow -= newflow;
          flow += newflow;
          cp -= newflow;
          if (cp == 0) {
            break;
          }
        }
      }
    }
    return flow;
  }
  long long Dinic() {
    long long flow = 0;
    while (bfs()) {
      memset(cur, 0, sizeof(cur));
      flow += dfs(s, 10000000000ll);
    }
    return flow;
  }
};
Maxflow mf;
unordered_map<int, vector<int>> hz;
unordered_map<int, vector<int>> vc;
int tx[3111], ty[3111];
vector<pair<pair<int, int>, int>> hs, vs;
int x[3111], y[3111];
set<pair<pair<int, int>, int>> elih, eliv;
set<pair<int, int>> valid;
vector<pair<pair<int, int>, int>> ansh, ansv;
int visited[3111];
void dfs(int v) {
  visited[v] = 1;
  for (auto idx : mf.g[v]) {
    auto e = mf.edg[idx];
    if (e.flow != e.capacity && !visited[e.to]) {
      dfs(e.to);
    }
  }
}
int main() {
  int n, i, j;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i) {
    scanf("%d%d", &tx[i], &ty[i]);
    hz[ty[i]].push_back(tx[i]);
    vc[tx[i]].push_back(ty[i]);
    x[i] = tx[i], y[i] = ty[i];
    valid.insert(make_pair(x[i], y[i]));
  }
  mf.s = 0, mf.t = 3111 - 1;
  auto iter = hz.begin();
  while (iter != hz.end()) {
    sort(iter->second.begin(), iter->second.end());
    for (i = 1; i < (int)iter->second.size(); ++i) {
      hs.push_back(make_pair(make_pair(iter->second[i - 1], iter->second[i]),
                             iter->first));
    }
    ++iter;
  }
  iter = vc.begin();
  while (iter != vc.end()) {
    sort(iter->second.begin(), iter->second.end());
    for (i = 1; i < (int)iter->second.size(); ++i) {
      vs.push_back(make_pair(make_pair(iter->second[i - 1], iter->second[i]),
                             iter->first));
    }
    ++iter;
  }
  int sz1 = hs.size(), sz2 = vs.size();
  for (i = 1; i <= sz1; ++i) {
    mf.addedge(mf.s, i, 1);
  }
  for (i = 1; i <= sz2; ++i) {
    mf.addedge(i + sz1, mf.t, 1);
  }
  for (i = 1; i <= sz1; ++i) {
    for (j = 1; j <= sz2; ++j) {
      auto p1 = hs[i - 1], p2 = vs[j - 1];
      int x1 = p1.first.first, x2 = p1.first.second, y = p1.second;
      int y1 = p2.first.first, y2 = p2.first.second, x = p2.second;
      if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
        if (valid.find(make_pair(x, y)) == valid.end()) {
          mf.addedge(i, j + sz1, 10000000000ll);
        }
      }
    }
  }
  mf.Dinic();
  dfs(mf.s);
  for (auto e : mf.edg) {
    if (visited[e.from] && !visited[e.to]) {
      if (e.from == mf.s && e.to <= sz1 && e.flow == e.capacity) {
        elih.insert(hs[e.to - 1]);
      }
      if (e.to == mf.t && e.from > sz1 && e.flow == e.capacity) {
        eliv.insert(vs[e.from - sz1 - 1]);
      }
    }
  }
  iter = hz.begin();
  while (iter != hz.end()) {
    int low = iter->second[0], high = iter->second[0], y = iter->first;
    for (i = 0; i < (int)iter->second.size() - 1; ++i) {
      int x1 = iter->second[i], x2 = iter->second[i + 1];
      if (elih.find(make_pair(make_pair(x1, x2), y)) == elih.end()) {
        high = x2;
      } else {
        ansh.push_back(make_pair(make_pair(low, high), y));
        low = x2, high = x2;
      }
    }
    ansh.push_back(make_pair(make_pair(low, high), y));
    ++iter;
  }
  iter = vc.begin();
  while (iter != vc.end()) {
    int low = iter->second[0], high = iter->second[0], y = iter->first;
    for (i = 0; i < (int)iter->second.size() - 1; ++i) {
      int x1 = iter->second[i], x2 = iter->second[i + 1];
      if (eliv.find(make_pair(make_pair(x1, x2), y)) == eliv.end()) {
        high = x2;
      } else {
        ansv.push_back(make_pair(make_pair(low, high), y));
        low = x2, high = x2;
      }
    }
    ansv.push_back(make_pair(make_pair(low, high), y));
    ++iter;
  }
  printf("%d\n", (int)ansh.size());
  for (auto p : ansh) {
    printf("%d %d %d %d\n", p.first.first, p.second, p.first.second, p.second);
  }
  printf("%d\n", (int)ansv.size());
  for (auto p : ansv) {
    printf("%d %d %d %d\n", p.second, p.first.first, p.second, p.first.second);
  }
  return 0;
}