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;
  Point() {}
  Point(int a, int b) {
    x = a;
    y = b;
  }
  bool operator==(const Point& p) const { return (x == p.x && y == p.y); }
};
using namespace std;
const int M = 1000;
const int V = M << 2;
const int inf = 1000 * 1000;
int n;
Point point[M];
int vNumber, hNumber;
pair<Point, Point> ver[M];
pair<Point, Point> hor[M];
int size;
int source;
int sink;
bool visited[V];
vector<int> N[V];
vector<int> C[V];
vector<int> W[V];
vector<int> R[V];
vector<pair<int, int> > path;
vector<pair<Point, Point> > blue;
vector<pair<Point, Point> > red;
void read();
void makeSegments();
bool compare_by_x(Point, Point);
bool compare_by_y(Point, Point);
bool compare(int, int, int, int);
void printSegments();
void makeGraph();
void addEdge(int, int, int);
bool intersect(int, int);
void printGraph();
int findFlow();
void setVisited();
bool findPath(int);
int getFlow();
void updateGraph(int);
void makeRed();
void makeBlue();
bool minCut(int, int);
void printRed();
bool horizental_compare(pair<Point, Point>, pair<Point, Point>);
void printBlue();
bool vertical_compare(pair<Point, Point>, pair<Point, Point>);
int main() {
  read();
  makeSegments();
  makeGraph();
  findFlow();
  makeRed();
  makeBlue();
  printRed();
  printBlue();
  return 0;
}
void read() {
  ios_base ::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 0; i < n; i++) cin >> point[i].x >> point[i].y;
}
void makeSegments() {
  sort(point, point + n, compare_by_x);
  for (int i = 1; i < n; i++) {
    if (point[i].x == point[i - 1].x) {
      vNumber++;
      ver[vNumber].first = point[i - 1];
      ver[vNumber].second = point[i];
    }
  }
  sort(point, point + n, compare_by_y);
  for (int i = 1; i < n; i++) {
    if (point[i].y == point[i - 1].y) {
      hNumber++;
      hor[hNumber].first = point[i - 1];
      hor[hNumber].second = point[i];
    }
  }
}
bool compare_by_x(Point a, Point b) { return compare(a.x, b.x, a.y, b.y); }
bool compare_by_y(Point a, Point b) { return compare(a.y, b.y, a.x, b.x); }
bool compare(int a, int b, int c, int d) {
  if (a == b)
    return c < d;
  else
    return a < b;
}
void printSegments() {
  printf("Vertical Segments:\n");
  for (int i = 1; i <= vNumber; i++) {
    Point a = ver[i].first;
    Point b = ver[i].second;
    printf("(%d , %d) --- (%d , %d)\n", a.x, a.y, b.x, b.y);
  }
  printf("Horizental Segments:\n");
  for (int i = 1; i <= hNumber; i++) {
    Point a = hor[i].first;
    Point b = hor[i].second;
    printf("(%d , %d) --- (%d , %d)\n", a.x, a.y, b.x, b.y);
  }
}
void makeGraph() {
  size = (vNumber << 1) + (hNumber << 1) + 2;
  source = 0;
  sink = size - 1;
  int match = vNumber + hNumber;
  for (int v = 1; v <= vNumber; v++) {
    addEdge(source, v, inf);
    addEdge(v, v + match, 1);
  }
  for (int v = vNumber + 1; v <= vNumber + hNumber; v++) {
    addEdge(v, sink, inf);
    addEdge(v + match, v, 1);
  }
  for (int u = match + 1; u <= match + vNumber; u++) {
    for (int v = match + vNumber + 1; v < sink; v++) {
      int i = u - match;
      int j = v - match - vNumber;
      if (intersect(i, j)) addEdge(u, v, inf);
    }
  }
}
void addEdge(int u, int v, int cap) {
  R[u].push_back(N[v].size());
  R[v].push_back(N[u].size());
  N[u].push_back(v);
  N[v].push_back(u);
  C[u].push_back(cap);
  C[v].push_back(0);
  W[u].push_back(cap);
  W[v].push_back(0);
}
bool intersect(int i, int j) {
  Point a = ver[i].first;
  Point b = ver[i].second;
  Point c = hor[j].first;
  Point d = hor[j].second;
  if (c.y <= a.y || c.y >= b.y) return false;
  if (a.x <= c.x || a.x >= d.x) return false;
  return true;
}
void printGraph() {
  printf("V = %d\n", size);
  printf("Source = %d\n", source);
  printf("Sink = %d\n", sink);
  for (int v = 0; v < size; v++) {
    printf("N[%d] = {", v);
    for (int i = 0; i < N[v].size(); i++) {
      int u = N[v][i];
      if (i > 0) printf(" , ");
      printf("%d", u);
    }
    printf("}\n");
    printf("C[%d] = {", v);
    for (int i = 0; i < C[v].size(); i++) {
      int c = C[v][i];
      if (i > 0) printf(" , ");
      printf("%d", c);
    }
    printf("}\n");
    printf("R[%d] = {", v);
    for (int i = 0; i < R[v].size(); i++) {
      int r = R[v][i];
      if (i > 0) printf(" , ");
      printf("%d", r);
    }
    printf("}\n");
    printf("*************************\n");
  }
}
int findFlow() {
  int maximumFlow = 0;
  while (true) {
    setVisited();
    path.clear();
    bool found = findPath(source);
    if (found) {
      int flow = getFlow();
      updateGraph(flow);
      maximumFlow += flow;
    } else
      break;
  }
  return maximumFlow;
}
void setVisited() {
  for (int v = 0; v < size; v++) visited[v] = false;
}
bool findPath(int v) {
  visited[v] = true;
  path.push_back(pair<int, int>(v, 0));
  if (v == sink) return true;
  for (int i = 0; i < N[v].size(); i++) {
    int u = N[v][i];
    int c = W[v][i];
    if (!visited[u] && c > 0) {
      (path.back()).second = i;
      bool found = findPath(u);
      if (found) return true;
    }
  }
  path.pop_back();
  return false;
}
int getFlow() {
  int res = inf;
  for (int i = 0; i < path.size() - 1; i++) {
    int u = path[i].first;
    int j = path[i].second;
    res = min(res, W[u][j]);
  }
  return res;
}
void updateGraph(int flow) {
  for (int i = 0; i < path.size() - 1; i++) {
    int u = path[i].first;
    int j = path[i].second;
    int k = R[u][j];
    int v = N[u][j];
    W[u][j] -= flow;
    W[v][k] += flow;
  }
}
void makeRed() {
  for (int i = 1; i <= hNumber; i++) {
    int v = vNumber + hNumber + vNumber + i;
    if (!minCut(v, 0)) {
      pair<Point, Point> p(hor[i].first, hor[i].second);
      red.push_back(p);
    }
  }
  for (int i = 0; i < n; i++) {
    Point p = point[i];
    bool found = false;
    for (int j = 0; j < red.size(); j++) {
      if (p == red[j].first || p == red[j].second) {
        found = true;
        break;
      }
    }
    if (!found) {
      pair<Point, Point> newPair(p, p);
      red.push_back(newPair);
    }
  }
}
void makeBlue() {
  for (int i = 1; i <= vNumber; i++) {
    int v = i;
    if (!minCut(v, 1)) {
      pair<Point, Point> p(ver[i].first, ver[i].second);
      blue.push_back(p);
    }
  }
  for (int i = 0; i < n; i++) {
    Point p = point[i];
    bool found = false;
    for (int j = 0; j < blue.size(); j++) {
      if (p == blue[j].first || p == blue[j].second) {
        found = true;
        break;
      }
    }
    if (!found) {
      pair<Point, Point> newPair(p, p);
      blue.push_back(newPair);
    }
  }
}
bool minCut(int u, int i) {
  int v = N[u][i];
  return (visited[u] && !visited[v]);
}
void printRed() {
  vector<pair<Point, Point> > res;
  sort(red.begin(), red.end(), horizental_compare);
  Point a = red[0].first;
  Point b = red[0].second;
  for (int i = 1; i < red.size(); i++) {
    if (red[i].first == b)
      b = red[i].second;
    else {
      pair<Point, Point> newPair(a, b);
      res.push_back(newPair);
      a = red[i].first;
      b = red[i].second;
    }
  }
  pair<Point, Point> newPair(a, b);
  res.push_back(newPair);
  printf("%lu\n", res.size());
  for (int i = 0; i < res.size(); i++) {
    Point a = res[i].first;
    Point b = res[i].second;
    printf("%d %d %d %d\n", a.x, a.y, b.x, b.y);
  }
}
bool horizental_compare(pair<Point, Point> a, pair<Point, Point> b) {
  return compare_by_y(a.first, b.first);
}
void printBlue() {
  vector<pair<Point, Point> > res;
  sort(blue.begin(), blue.end(), vertical_compare);
  Point a = blue[0].first;
  Point b = blue[0].second;
  for (int i = 1; i < blue.size(); i++) {
    if (blue[i].first == b)
      b = blue[i].second;
    else {
      pair<Point, Point> newPair(a, b);
      res.push_back(newPair);
      a = blue[i].first;
      b = blue[i].second;
    }
  }
  pair<Point, Point> newPair(a, b);
  res.push_back(newPair);
  printf("%lu\n", res.size());
  for (int i = 0; i < res.size(); i++) {
    Point a = res[i].first;
    Point b = res[i].second;
    printf("%d %d %d %d\n", a.x, a.y, b.x, b.y);
  }
}
bool vertical_compare(pair<Point, Point> a, pair<Point, Point> b) {
  return compare_by_x(a.first, b.first);
}