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 Edge {
  int t, f, next;
  Edge() {}
  Edge(int a, int b, int c) : t(a), f(b), next(c) {}
};
Edge e[2000000];
int head[2005], vs, vt, tot = -1;
void addEdge(int x, int y, int z) {
  e[++tot] = Edge(y, z, head[x]);
  head[x] = tot;
  e[++tot] = Edge(x, 0, head[y]);
  head[y] = tot;
}
namespace Flow {
int d[2005], cur[2005];
queue<int> q;
bool bfs() {
  while (!q.empty()) q.pop();
  memset(d, 255, sizeof(d));
  d[vs] = 0;
  cur[vs] = head[vs];
  q.push(vs);
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (int i = head[x]; i != -1; i = e[i].next)
      if (e[i].f && d[e[i].t] == -1) {
        int u = e[i].t;
        d[u] = d[x] + 1;
        cur[u] = head[u];
        if (u == vt) return 1;
        q.push(u);
      }
  }
  return 0;
}
int dfs(int x, int a) {
  if (x == vt || !a) return a;
  int ans = 0;
  for (int &i = cur[x]; i != -1; i = e[i].next)
    if (e[i].f && d[e[i].t] == d[x] + 1) {
      int u = e[i].t;
      int f = dfs(u, min(a, e[i].f));
      if (f) {
        e[i].f -= f;
        e[i ^ 1].f += f;
        ans += f;
        a -= f;
        if (!a) break;
      }
    }
  return ans;
}
int maxflow() {
  int ans = 0;
  while (bfs()) ans += dfs(vs, 0x3f3f3f3f);
  bfs();
  return ans;
}
}  // namespace Flow
struct Point {
  int x, y;
  bool v;
  Point() {}
  Point(int a, int b, bool c) : x(a), y(b), v(c) {}
};
struct Line {
  Point l, r;
  Line() {}
  Line(Point a, Point b) : l(a), r(b) {}
};
int num[2005];
Point p[1005];
vector<Point> row[2005], col[2005];
Line rl[2005], cl[2005];
bool cmp1(Point x, Point y) { return x.y < y.y; }
bool cmp2(Point x, Point y) { return x.x < y.x; }
int main() {
  memset(head, 255, sizeof(head));
  int n;
  scanf("%d", &n);
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    p[i] = Point(x, y, 0);
    num[++cnt] = x;
    num[++cnt] = y;
  }
  sort(num + 1, num + cnt + 1);
  cnt = unique(num + 1, num + cnt + 1) - num - 1;
  for (int i = 1; i <= n; i++) {
    p[i].x = lower_bound(num + 1, num + cnt + 1, p[i].x) - num;
    p[i].y = lower_bound(num + 1, num + cnt + 1, p[i].y) - num;
    row[p[i].x].push_back(p[i]);
    col[p[i].y].push_back(p[i]);
  }
  for (int i = 1; i <= cnt; i++) sort(row[i].begin(), row[i].end(), cmp1);
  for (int i = 1; i <= cnt; i++) sort(col[i].begin(), col[i].end(), cmp2);
  int s1 = 0, s2 = 0;
  for (int i = 1; i <= cnt; i++)
    if (row[i].size() > 1) {
      for (int j = 0; j < row[i].size() - 1; j++)
        rl[++s1] = Line(row[i][j], row[i][j + 1]);
    }
  for (int i = 1; i <= cnt; i++)
    if (col[i].size() > 1) {
      for (int j = 0; j < col[i].size() - 1; j++)
        cl[++s2] = Line(col[i][j], col[i][j + 1]);
    }
  vs = 0;
  vt = s1 + s2 + 1;
  for (int i = 1; i <= s1; i++) addEdge(vs, i, 1);
  for (int i = 1; i <= s2; i++) addEdge(s1 + i, vt, 1);
  for (int i = 1; i <= s1; i++)
    for (int j = 1; j <= s2; j++)
      if (rl[i].l.y < cl[j].l.y && rl[i].r.y > cl[j].l.y &&
          cl[j].l.x < rl[i].l.x && cl[j].r.x > rl[i].l.x)
        addEdge(i, s1 + j, 1);
  Flow::maxflow();
  int sz1 = n, sz2 = n;
  for (int i = 1; i <= s1; i++)
    if (Flow::d[i] != -1) {
      int x = rl[i].l.x;
      for (int j = 0; j < row[x].size(); j++)
        if (row[x][j].y == rl[i].l.y) row[x][j].v = 1;
      sz1--;
    }
  for (int i = 1; i <= s2; i++)
    if (Flow::d[s1 + i] == -1) {
      int x = cl[i].l.y;
      for (int j = 0; j < col[x].size(); j++)
        if (col[x][j].x == cl[i].l.x) col[x][j].v = 1;
      sz2--;
    }
  printf("%d\n", sz2);
  for (int i = 1; i <= cnt; i++)
    if (col[i].size()) {
      int last2 = -1;
      for (int j = 0; j < col[i].size(); j++)
        if (!col[i][j].v) {
          printf("%d %d %d %d\n", num[col[i][last2 + 1].x],
                 num[col[i][last2 + 1].y], num[col[i][j].x], num[col[i][j].y]);
          last2 = j;
        }
    }
  printf("%d\n", sz1);
  for (int i = 1; i <= cnt; i++)
    if (row[i].size()) {
      int last2 = -1;
      for (int j = 0; j < row[i].size(); j++)
        if (!row[i][j].v) {
          printf("%d %d %d %d\n", num[row[i][last2 + 1].x],
                 num[row[i][last2 + 1].y], num[row[i][j].x], num[row[i][j].y]);
          last2 = j;
        }
    }
  return 0;
}