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;
const double eps = 1e-9;
const int oo = 0x3f3f3f3f;
struct line {
  int x0, y0, x1, y1;
};
bool intersect(line h, line v) {
  return v.x0 < h.x0 && h.x0 < v.x1 && h.y0 < v.y0 && v.y0 < h.y1;
}
template <typename flow_type>
struct dinic {
  struct edge {
    size_t src, dst, rev;
    flow_type flow, cap;
  };
  int n;
  vector<vector<edge>> adj;
  dinic(int n) : n(n), adj(n), level(n), q(n), it(n) {}
  void add_edge(size_t src, size_t dst, flow_type cap, flow_type rcap = 0) {
    adj[src].push_back({src, dst, adj[dst].size(), 0, cap});
    if (src == dst) adj[src].back().rev++;
    adj[dst].push_back({dst, src, adj[src].size() - 1, 0, rcap});
  }
  vector<int> level, q, it;
  bool bfs(int source, int sink) {
    fill(level.begin(), level.end(), -1);
    for (int qf = level[q[0] = sink] = 0, qb = 1; qf < qb; ++qf) {
      sink = q[qf];
      for (edge &e : adj[sink]) {
        edge &r = adj[e.dst][e.rev];
        if (r.flow < r.cap && level[e.dst] == -1)
          level[q[qb++] = e.dst] = 1 + level[sink];
      }
    }
    return level[source] != -1;
  }
  flow_type augment(int source, int sink, flow_type flow) {
    if (source == sink) return flow;
    for (; it[source] != adj[source].size(); ++it[source]) {
      edge &e = adj[source][it[source]];
      if (e.flow < e.cap && level[e.dst] + 1 == level[source]) {
        flow_type delta = augment(e.dst, sink, min(flow, e.cap - e.flow));
        if (delta > 0) {
          e.flow += delta;
          adj[e.dst][e.rev].flow -= delta;
          return delta;
        }
      }
    }
    return 0;
  }
  flow_type max_flow(int source, int sink) {
    for (int u = 0; u < n; ++u)
      for (edge &e : adj[u]) e.flow = 0;
    flow_type flow = 0;
    flow_type oo = numeric_limits<flow_type>::max();
    while (bfs(source, sink)) {
      fill(it.begin(), it.end(), 0);
      for (flow_type f; (f = augment(source, sink, oo)) > 0;) flow += f;
    }
    return flow;
  }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  map<int, vector<int>> X, Y;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    X[x].push_back(y);
    Y[y].push_back(x);
  }
  vector<line> H, V;
  for (auto &xx : X) {
    int x = xx.first;
    sort(xx.second.begin(), xx.second.end());
    for (int i = 1; i < (int)xx.second.size(); ++i) {
      int y0 = xx.second[i - 1], y1 = xx.second[i];
      H.push_back({x, y0, x, y1});
    }
  }
  for (auto &yy : Y) {
    int y = yy.first;
    sort(yy.second.begin(), yy.second.end());
    for (int i = 1; i < (int)yy.second.size(); ++i) {
      int x0 = yy.second[i - 1], x1 = yy.second[i];
      V.push_back({x0, y, x1, y});
    }
  }
  int N = H.size() + V.size() + 2;
  dinic<int> g(N);
  int hsize = H.size();
  for (int i = 0; i < (int)H.size(); ++i) {
    g.add_edge(0, i + 2, 1);
    for (int j = 0; j < (int)V.size(); ++j) {
      if (intersect(H[i], V[j])) {
        g.add_edge(i + 2, j + hsize + 2, 1);
      }
    }
  }
  for (int j = 0; j < (int)V.size(); ++j) g.add_edge(j + hsize + 2, 1, 1);
  int ans = g.max_flow(0, 1);
  vector<bool> okH(H.size()), okV(V.size());
  int hor = n, ver = n;
  for (int i = 2; i < N; ++i) {
    if (i < 2 + hsize) {
      if (g.level[i] == -1) {
        okH[i - 2] = true;
        hor--;
      }
    } else {
      if (g.level[i] != -1) {
        okV[i - 2 - hsize] = true;
        ver--;
      }
    }
  }
  cout << ver << '\n';
  for (int i = 0, j; i < V.size(); i = j) {
    vector<int> xlist;
    xlist.push_back(V[i].x0);
    for (j = i; j < (int)V.size() && V[j].y0 == V[i].y0; ++j) {
      if (!okV[j]) {
        xlist.push_back(V[j].x0);
        xlist.push_back(V[j].x1);
      }
    }
    xlist.push_back(V[j - 1].x1);
    int y = V[i].y0;
    for (int k = 0; k < (int)xlist.size(); k += 2) {
      cout << xlist[k] << " " << y << " " << xlist[k + 1] << " " << y << '\n';
    }
  }
  for (auto t : Y) {
    if (t.second.size() == 1)
      cout << t.second[0] << " " << t.first << " " << t.second[0] << " "
           << t.first << '\n';
  }
  cout << hor << '\n';
  for (int i = 0, j; i < H.size(); i = j) {
    vector<int> ylist;
    ylist.push_back(H[i].y0);
    for (j = i; j < (int)H.size() && H[j].x0 == H[i].x0; ++j) {
      if (!okH[j]) {
        ylist.push_back(H[j].y0);
        ylist.push_back(H[j].y1);
      }
    }
    ylist.push_back(H[j - 1].y1);
    int x = H[i].x0;
    for (int k = 0; k < (int)ylist.size(); k += 2) {
      cout << x << " " << ylist[k] << " " << x << " " << ylist[k + 1] << '\n';
    }
  }
  for (auto t : X) {
    if (t.second.size() == 1)
      cout << t.first << " " << t.second[0] << " " << t.first << " "
           << t.second[0] << '\n';
  }
}