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>
struct Point {
  int x, y;
  int id;
};
using std::vector;
Point a[1005];
int mapX[1005], mapY[1005];
vector<Point> row[1005];
vector<Point> col[1005];
int id[2000005];
vector<int> g[4005];
int vis[4005];
int match[4005];
int edgeSet[4005];
int tag[4005];
int p[4005];
int lx[4005], rx[4005], ly[4005], ry[4005];
int keepX[4005], keepY[4005];
int getId(int u, int n, int map[]) {
  int L = 1, R = n;
  int res = -1;
  while (L <= R) {
    int M = (L + R) / 2;
    if (map[M] <= u) {
      res = M;
      L = M + 1;
    } else
      R = M - 1;
  }
  return res;
}
int getMap(int n, int map[]) {
  std::sort(map + 1, map + 1 + n);
  int p = 1, size = 0;
  while (p <= n) {
    int np = p;
    while (np + 1 <= n && map[np + 1] == map[p]) np++;
    map[++size] = map[p];
    p = np + 1;
  }
  return size;
}
void preWork(int n) {
  int sizeX = getMap(n, mapX), sizeY = getMap(n, mapY);
  for (int i = 1; i <= n; i++) {
    a[i].x = getId(a[i].x, sizeX, mapX);
    a[i].y = getId(a[i].y, sizeY, mapY);
  }
}
void addEdge(int u, int v) {
  g[u].push_back(v);
  g[v].push_back(u);
}
int dfs(int u) {
  for (int v : g[u]) {
    if (!vis[v]) {
      vis[v] = 1;
      if (!match[v] || dfs(match[v])) {
        match[v] = u;
        return 1;
      }
    }
  }
  return 0;
}
int matching(int n, int m) {
  int res = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n + m; j++) vis[j] = 0;
    res += dfs(i);
  }
  for (int i = n + 1; i <= n + m; i++) {
    if (match[i] != 0) tag[match[i]] = 1;
  }
  return res;
}
void getPath(int u) {
  vis[u] = 1;
  for (int v : g[u]) {
    if (!vis[v]) {
      vis[v] = 1;
      getPath(match[v]);
    }
  }
}
int find(int u) {
  if (p[u] == u)
    return p[u];
  else
    return p[u] = find(p[u]);
}
void merge(int x, int y) {
  int u = find(x), v = find(y);
  p[v] = u;
  if (lx[u] > lx[v]) lx[u] = lx[v];
  if (rx[u] < rx[v]) rx[u] = rx[v];
  if (ly[u] > ly[v]) ly[u] = ly[v];
  if (ry[u] < ry[v]) ry[u] = ry[v];
}
int getEdge(int n, int m, int size) {
  for (int i = 1; i <= n + m; i++) vis[i] = 0;
  for (int i = 1; i <= n; i++) {
    if (tag[i] == 0) {
      getPath(i);
    }
  }
  for (int i = 1; i <= 2 * size; i++) {
    p[i] = i;
    int j = i;
    if (j > size) j -= size;
    lx[i] = rx[i] = a[j].x;
    ly[i] = ry[i] = a[j].y;
  }
  int res = 0;
  for (int i = 1; i <= n + m; i++) {
    if ((i <= n && vis[i]) || (i > n && !vis[i])) {
      res++;
      Point u = a[edgeSet[i] / 1001], v = a[edgeSet[i] % 1001];
      if (u.x == v.x)
        merge(u.id, v.id);
      else
        merge(u.id + size, v.id + size);
    }
  }
  return res;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
    a[i].id = i;
    mapX[i] = a[i].x, mapY[i] = a[i].y;
  }
  preWork(n);
  std::sort(a + 1, a + 1 + n, [&](Point& u, Point& v) { return u.x < v.x; });
  for (int i = 1; i <= n; i++) col[a[i].y].push_back(a[i]);
  std::sort(a + 1, a + 1 + n, [&](Point& u, Point& v) { return u.y < v.y; });
  for (int i = 1; i <= n; i++) row[a[i].x].push_back(a[i]);
  int total = 0;
  for (int i = 1; i <= n; i++) {
    if (col[i].size() >= 2) {
      int size = col[i].size();
      for (int j = 0; j < size - 1; j++) {
        int u = col[i][j].id, v = col[i][j + 1].id;
        int mask = u * 1001 + v;
        if (id[mask] == 0) {
          id[mask] = ++total;
          edgeSet[total] = mask;
        }
      }
    }
  }
  int stop = total;
  for (int i = n; i >= 1; i--) {
    if (row[i].size() >= 2) {
      int size = row[i].size();
      for (int j = 0; j < size - 1; j++) {
        int u = row[i][j].id, v = row[i][j + 1].id;
        int mask = u * 1001 + v;
        if (id[mask] == 0) {
          id[mask] = ++total;
          edgeSet[total] = mask;
        }
        for (int k = row[i][j].y + 1; k <= row[i][j + 1].y - 1; k++) {
          while (col[k].size() >= 2) {
            int tail = col[k].size() - 2;
            if (col[k][tail].x > i)
              col[k].pop_back();
            else
              break;
          }
          if (col[k].size() >= 2) {
            int tail = col[k].size() - 2;
            Point down = col[k][tail], up = col[k][col[k].size() - 1];
            if (down.x < i && up.x > i) {
              int u = id[mask], v = id[down.id * 1001 + up.id];
              addEdge(u, v);
            }
          }
        }
      }
    }
  }
  int maxEdge = total - matching(stop, total - stop);
  std::sort(a + 1, a + 1 + n, [&](Point& u, Point& v) { return u.id < v.id; });
  int realEdge = getEdge(stop, total - stop, n);
  for (int i = 1; i <= 2 * n; i++) vis[i] = 0;
  int sizeX = 0, sizeY = 0;
  for (int i = 1; i <= 2 * n; i++) {
    int u = find(i);
    if (!vis[u]) {
      vis[u] = 1;
      if (i <= n)
        keepX[++sizeX] = u;
      else
        keepY[++sizeY] = u;
    }
  }
  printf("%d\n", sizeY);
  for (int i = 1; i <= sizeY; i++) {
    int u = keepY[i];
    printf("%d %d %d %d\n", mapX[lx[u]], mapY[ly[u]], mapX[rx[u]], mapY[ry[u]]);
  }
  printf("%d\n", sizeX);
  for (int i = 1; i <= sizeX; i++) {
    int u = keepX[i];
    printf("%d %d %d %d\n", mapX[lx[u]], mapY[ly[u]], mapX[rx[u]], mapY[ry[u]]);
  }
  return 0;
}