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;
template <typename T>
inline bool chkmin(T &a, const T &b) {
  return a > b ? a = b, 1 : 0;
}
template <typename T>
inline bool chkmax(T &a, const T &b) {
  return a < b ? a = b, 1 : 0;
}
template <typename T>
inline bool smin(T &a, const T &b) {
  return a > b ? a = b : a;
}
template <typename T>
inline bool smax(T &a, const T &b) {
  return a < b ? a = b : a;
}
const int N = (int)2005, mod = (int)0;
vector<int> px, py;
int xmx[N], mark[N], match[N], par[2][N][N], xl[N], xr[N], yl[N], yr[N], xmn[N],
    ymx[N], ymn[N], ax[N], ay[N], bx[N], by[N];
;
vector<int> res, adj[N], all[2][N];
int find(int first, int *par) {
  return first == par[first] ? first : par[first] = find(par[first], par);
}
void dfs_see(int v) {
  if (v == -1) return;
  if (mark[v]) return;
  res.push_back(v);
  mark[v] = 1;
  for (int u : adj[v])
    if (!mark[u]) {
      mark[u] = 1;
      dfs_see(match[u]);
    }
}
int dfs(int v) {
  if (v == -1) return 1;
  if (mark[v]) return 0;
  mark[v] = 1;
  for (int u : adj[v])
    if (dfs(match[u])) {
      match[u] = v;
      match[v] = u;
      return 1;
    }
  return 0;
}
int unite(int u, int v, int *par) {
  u = find(u, par);
  v = find(v, par);
  if (u == v) return 0;
  par[u] = v;
  return 1;
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> ax[i] >> ay[i];
    px.push_back(ax[i]);
    py.push_back(ay[i]);
  }
  sort((px).begin(), (px).end());
  sort((py).begin(), (py).end());
  px.resize(unique((px).begin(), (px).end()) - px.begin());
  py.resize(unique((py).begin(), (py).end()) - py.begin());
  for (int i = 0; i < n; ++i) {
    bx[i] = ax[i];
    by[i] = ay[i];
    ax[i] = lower_bound((px).begin(), (px).end(), ax[i]) - px.begin();
    ay[i] = lower_bound((py).begin(), (py).end(), ay[i]) - py.begin();
    all[0][ax[i]].push_back(ay[i]);
    all[1][ay[i]].push_back(ax[i]);
  }
  for (int r = 0; r <= 1; ++r)
    for (int i = 0; i < N; ++i) sort((all[r][i]).begin(), (all[r][i]).end());
  int c0 = 0, c1 = 0, c = 0;
  for (int r = 0; r <= 1; ++r)
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < (int)all[r][i].size() - 1; ++j) {
        int &px = xl[c], &py = yl[c], &qx = xr[c], &qy = yr[c];
        if (r == 0) {
          px = qx = i;
          py = all[r][i][j];
          qy = all[r][i][j + 1];
        } else {
          py = qy = i;
          px = all[r][i][j];
          qx = all[r][i][j + 1];
        }
        ++c;
        if (r == 0)
          c0++;
        else
          c1++;
      }
  for (int j = 0; j < c0; ++j)
    for (int i = c0; i < c; ++i) {
      if (yl[j] < yl[i] && yl[i] < yr[j] && xl[i] < xl[j] && xl[j] < xr[i]) {
        adj[i].push_back(j);
        adj[j].push_back(i);
      }
    }
  memset(match, -1, sizeof match);
  for (int i = 0; i < c0; ++i)
    if (match[i] == -1) {
      memset(mark, 0, sizeof mark);
      dfs(i);
    }
  memset(mark, 0, sizeof mark);
  for (int i = 0; i < c0; ++i)
    if (match[i] == -1) dfs_see(i);
  for (int i = c0; i < c; ++i)
    if (match[i] != -1 && !mark[i]) res.push_back(i);
  memset(mark, 0, sizeof mark);
  for (int i = c0; i < c; ++i)
    if (match[i] == -1) dfs_see(i);
  for (int r = 0; r <= 1; ++r)
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < N; ++j) par[r][i][j] = j;
  memset(mark, 0, sizeof mark);
  for (int j : res) mark[j] = 1;
  for (int j : res) {
    if (j < c0) {
      unite(yl[j], yr[j], par[0][xl[j]]);
    } else {
      unite(xl[j], xr[j], par[1][yl[j]]);
    }
  }
  vector<pair<int, pair<int, int>>> red, blue;
  for (int i = 0; i < N; ++i) {
    if (all[0][i].size()) {
      int mx = -1;
      for (int j = 0; j < (int)all[0][i].size(); ++j) {
        int pos = all[0][i][j];
        if (pos > mx) {
          int nxt = find(pos, par[0][i]);
          mx = max(mx, nxt);
          red.push_back(make_pair(i, make_pair(pos, nxt)));
        }
      }
    }
    if (all[1][i].size()) {
      int mx = -1;
      for (int j = 0; j < (int)all[1][i].size(); ++j) {
        int pos = all[1][i][j];
        if (pos > mx) {
          int nxt = find(pos, par[1][i]);
          mx = max(mx, nxt);
          blue.push_back(make_pair(i, make_pair(pos, nxt)));
        }
      }
    }
  }
  cout << (int)blue.size() << endl;
  for (auto first : blue)
    cout << px[first.second.first] << ' ' << py[first.first] << ' '
         << px[first.second.second] << ' ' << py[first.first] << '\n';
  cout << (int)red.size() << endl;
  for (auto first : red)
    cout << px[first.first] << ' ' << py[first.second.first] << ' '
         << px[first.first] << ' ' << py[first.second.second] << '\n';
}