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 int FN = 2005, INF = (int)1e9;
const int N = 1005;
struct point {
  int x, y;
  point(int _x, int _y) { x = _x, y = _y; }
  bool operator<(const point &other) const {
    return x == other.x ? y < other.y : x < other.x;
  }
};
struct edge {
  int to, cap, rev;
  edge(int _to, int _cap, int _rev) { to = _to, cap = _cap, rev = _rev; }
};
vector<edge> G[FN];
bool used[FN];
void add_edge(int from, int to, int cap) {
  G[from].push_back(edge(to, cap, G[to].size()));
  G[to].push_back(edge(from, 0, G[from].size() - 1));
}
int dfs(int v, int t, int f) {
  if (v == t) return f;
  used[v] = true;
  for (int i = 0; i < G[v].size(); i++) {
    edge &e = G[v][i];
    if (!used[e.to] && e.cap > 0) {
      int d = dfs(e.to, t, min(e.cap, f));
      if (d > 0) {
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
int max_flow(int s, int t) {
  int f = 0;
  for (;;) {
    fill(used, used + FN, false);
    int d = dfs(s, t, INF);
    if (d == 0) return f;
    f += d;
  }
}
map<int, int> mpx, mpy;
int cntx = 0, cnty = 0;
int x_id(int x) {
  if (!mpx.count(x)) mpx[x] = cntx++;
  return mpx[x];
}
int y_id(int y) {
  if (!mpy.count(y)) mpy[y] = cnty++;
  return mpy[y];
}
bool btw(int &x, int &l, int &r) { return x > l && x < r; }
bool inter(pair<point, point> &a, pair<point, point> &b) {
  return btw(a.first.x, b.first.x, b.second.x) &&
         btw(b.first.y, a.first.y, a.second.y);
}
void print_out(pair<point, point> a) {
  printf("%d %d %d %d\n", a.first.x, a.first.y, a.second.x, a.second.y);
}
int n;
int x[N], y[N];
vector<int> xt[N], yt[N];
vector<pair<point, point> > sx, sy;
vector<pair<point, point> > resx, resy;
int nx, ny;
bool take[FN], vis[FN];
bool cmpy(pair<point, point> a, pair<point, point> b) {
  return a.first.y == b.first.y ? a.first.x < b.first.x : a.first.y < b.first.y;
}
void dfs(int x) {
  vis[x] = true;
  take[x] = true;
  for (edge &e : G[x]) {
    if (e.cap > 0 && !vis[e.to]) dfs(e.to);
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    xt[x_id(x[i])].push_back(y[i]);
    yt[y_id(y[i])].push_back(x[i]);
  }
  for (int i = 0; i < cntx; i++) sort(xt[i].begin(), xt[i].end());
  for (int j = 0; j < cnty; j++) sort(yt[j].begin(), yt[j].end());
  for (auto p : mpx) {
    int x = p.first, i = p.second;
    if (xt[i].size() == 1)
      resx.push_back({point(x, xt[i][0]), point(x, xt[i][0])});
    for (int j = 0; j + 1 < xt[i].size(); j++)
      sx.push_back({point(x, xt[i][j]), point(x, xt[i][j + 1])});
  }
  for (auto p : mpy) {
    int y = p.first, i = p.second;
    if (yt[i].size() == 1)
      resy.push_back({point(yt[i][0], y), point(yt[i][0], y)});
    for (int j = 0; j + 1 < yt[i].size(); j++)
      sy.push_back({point(yt[i][j], y), point(yt[i][j + 1], y)});
  }
  sort(sx.begin(), sx.end());
  sort(sy.begin(), sy.end(), cmpy);
  nx = sx.size(), ny = sy.size();
  int s = nx + ny, t = s + 1;
  for (int i = 0; i < nx; i++) add_edge(s, i, 1);
  for (int i = 0; i < nx; i++) {
    for (int j = 0; j < ny; j++) {
      if (inter(sx[i], sy[j])) {
        add_edge(i, j + nx, 1);
      }
    }
  }
  for (int j = 0; j < ny; j++) add_edge(j + nx, t, 1);
  max_flow(s, t);
  dfs(s);
  for (int j = 0; j < ny; j++) take[j + nx] = !take[j + nx];
  bool exi = false;
  point a = point(-1, -1), b = point(-1, -1);
  for (int i = 0; i < nx; i++) {
    if (b.x != sx[i].first.x) {
      if (b.x != -1) resx.push_back({a, b});
      a = sx[i].first;
      b = sx[i].first;
    }
    if (take[i])
      b = sx[i].second;
    else {
      resx.push_back({a, b});
      a = b = sx[i].second;
    }
  }
  if (b.x != -1) resx.push_back({a, b});
  a = b = point(-1, -1);
  for (int j = 0; j < ny; j++) {
    if (b.y != sy[j].first.y) {
      if (b.y != -1) resy.push_back({a, b});
      a = sy[j].first;
      b = sy[j].first;
    }
    if (take[j + nx])
      b = sy[j].second;
    else {
      resy.push_back({a, b});
      a = b = sy[j].second;
    }
  }
  if (b.y != -1) resy.push_back({a, b});
  printf("%d\n", resy.size());
  for (auto p : resy) print_out(p);
  printf("%d\n", resx.size());
  for (auto p : resx) print_out(p);
}