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 Horizontal {
  int id, y, x0, x1;
};
struct Vertical {
  int id, x, y0, y1;
};
bool intersect(Vertical v, Horizontal h) {
  return v.y0 <= h.y && h.y <= v.y1 && (h.x0 <= v.x && v.x <= h.x1);
}
struct Point {
  int x, y;
  Point(int x, int y) : x(x), y(y) {}
  bool operator==(const Point &rhs) const { return x == rhs.x && y == rhs.y; }
  bool operator!=(const Point &rhs) const { return !(rhs == *this); }
  friend ostream &operator<<(ostream &os, const Point &point) {
    os << "x: " << point.x << " y: " << point.y;
    return os;
  }
};
struct Line {
  enum Type { VERTICAL, HORIZONTAL };
  Point a, b;
  Type type;
  int id;
  Line(const Point &a, const Point &b, Type type, int id)
      : a(a), b(b), type(type), id(id) {}
  bool intersect(const Line &o) const {
    assert(type != o.type);
    if (type == VERTICAL) {
      return a.y < o.a.y && o.a.y < b.y && o.a.x < a.x && a.x < o.b.x;
    } else {
      return a.x < o.a.x && o.a.x < b.x && o.a.y < a.y && a.y < o.b.y;
    }
  }
  bool operator==(const Line &rhs) const { return a == rhs.a && b == rhs.b; }
  bool operator!=(const Line &rhs) const { return !(rhs == *this); }
  Point intersection(const Line &o) const {
    return (type == VERTICAL) ? Point(a.x, o.a.y) : Point(o.a.x, a.y);
  }
};
struct MaxMatching {
  int L, R;
  vector<int> ML, MR;
  vector<vector<int>> adj;
  MaxMatching(int L, int R) : ML(L, -1), MR(R, -1), adj(L), L(L), R(R) {}
  void AddEdge(int u, int v) { adj[u].push_back(v); }
  int findMatch(int u, vector<int> &VIS) {
    if (VIS[u]) return 0;
    VIS[u] = 1;
    for (int v : adj[u]) {
      if (MR[v] == -1 || findMatch(MR[v], VIS)) {
        MR[v] = u;
        ML[u] = v;
        return 1;
      }
    }
    return 0;
  }
  int run() {
    vector<int> VIS(L);
    int cnt = 0;
    for (int i = 0; i < L; ++i) {
      VIS = vector<int>(L);
      cnt += findMatch(i, VIS);
    }
    return cnt;
  }
};
struct Konig {
  vector<int> ML, MR;
  vector<vector<int>> adj;
  int L, R, mc;
  Konig(int L, int R) : ML(L, -1), MR(R, -1), adj(L), L(L), R(R), mc(0) {}
  void AddEdge(int u, int v) { adj[u].push_back(v); }
  void setMatch(int u, int v) {
    ML[u] = v;
    MR[v] = u;
    mc++;
  }
  pair<vector<int>, vector<int>> getCover() {
    queue<int> QL;
    vector<int> VIS_L(L), VIS_R(R);
    for (int i = 0; i < L; ++i) {
      if (ML[i] == -1) {
        QL.push(i);
        VIS_L[i] = 1;
      }
    }
    while (QL.size()) {
      int u = QL.front();
      QL.pop();
      for (int i = 0; i < adj[u].size(); ++i) {
        int v = adj[u][i];
        if (MR[v] != -1 && !VIS_L[MR[v]]) {
          VIS_R[v] = 1;
          VIS_L[MR[v]] = 1;
          QL.push(MR[v]);
        }
      }
    }
    vector<int> AL, AR;
    for (int i = 0; i < L; ++i)
      if (!VIS_L[i]) AL.push_back(i);
    for (int i = 0; i < R; ++i)
      if (VIS_R[i]) AR.push_back(i);
    return make_pair(AL, AR);
  }
};
int main() {
  map<int, set<int>> BYX;
  map<int, set<int>> BYY;
  map<pair<int, int>, int> ID;
  int N;
  cin >> N;
  vector<pair<int, int>> V(N);
  for (int i = 0; i < N; ++i) {
    pair<int, int> &p = V[i];
    cin >> p.first >> p.second;
    ID[p] = i;
    BYX[p.first].insert(p.second);
    BYY[p.second].insert(p.first);
  }
  vector<Line> VER;
  vector<Line> HOR;
  for (auto p : BYX) {
    int x = p.first;
    int py = -1;
    if (p.second.size() == 1) py = *p.second.begin();
    for (int y : p.second) {
      if (py != -1) {
        int id = VER.size();
        VER.push_back(Line(Point(x, py), Point(x, y), Line::VERTICAL, id));
      }
      py = y;
    }
  }
  for (auto p : BYY) {
    int y = p.first;
    int px = -1;
    if (p.second.size() == 1) px = *p.second.begin();
    for (int x : p.second) {
      if (px != -1) {
        int id = HOR.size();
        HOR.push_back(Line(Point(px, y), Point(x, y), Line::HORIZONTAL, id));
      }
      px = x;
    }
  }
  MaxMatching MM(VER.size(), HOR.size());
  Konig KO(MM.L, MM.R);
  for (Line v : VER) {
    for (Line h : HOR) {
      if (v.intersect(h)) {
        MM.AddEdge(v.id, h.id);
        KO.AddEdge(v.id, h.id);
      }
    }
  }
  int mm = MM.run();
  for (int i = 0; i < MM.L; ++i) {
    if (MM.ML[i] != -1) {
      KO.setMatch(i, MM.ML[i]);
    }
  }
  auto cover = KO.getCover();
  assert(cover.first.size() + cover.second.size() == mm);
  vector<int> VERI(VER.size()), HORI(HOR.size());
  for (auto v : cover.first) VERI[v] = 1;
  for (auto h : cover.second) HORI[h] = 1;
  for (Line v : VER) {
    if (MM.ML[v.id] != -1) continue;
    for (Line h : HOR) {
      if (MM.MR[h.id] != -1) continue;
      assert(!v.intersect(h));
    }
  }
  for (Line v : VER) {
    if (VERI[v.id]) continue;
    for (Line h : HOR) {
      if (HORI[h.id]) continue;
      assert(!v.intersect(h));
    }
  }
  vector<Line> RV;
  auto addLine = [](vector<Line> &L, Line l, bool mandatory = false) {
    if (L.size() == 0 || L.back().b != l.a) {
      L.push_back(l);
    } else {
      assert(mandatory == false);
    }
  };
  for (int i = 0; i < VER.size(); ++i) {
    Line v = VER[i];
    if (VERI[i]) {
      addLine(RV, Line(v.a, v.a, v.type, v.id), false);
      if (i + 1 >= VER.size() || VER[i + 1].a.x != v.a.x) {
        addLine(RV, Line(v.b, v.b, v.type, v.id), false);
      }
    } else {
      for (int j = i; j < VER.size() && !VERI[j] && VER[j].a.x == v.a.x; ++j) {
        v.b = VER[j].b;
        i = j;
      }
      addLine(RV, v, true);
    }
  }
  vector<Line> RH;
  for (int i = 0; i < HOR.size(); ++i) {
    Line h = HOR[i];
    if (HORI[i]) {
      addLine(RH, Line(h.a, h.a, h.type, h.id), false);
      if (i + 1 >= HOR.size() || HOR[i + 1].a.y != h.a.y) {
        addLine(RH, Line(h.b, h.b, h.type, h.id), false);
      }
    } else {
      for (int j = i; j < HOR.size() && !HORI[j] && HOR[j].a.y == h.a.y; ++j) {
        h.b = HOR[j].b;
        i = j;
      }
      addLine(RH, h, true);
    }
  }
  cout << RH.size() << endl;
  for (Line h : RH) {
    cout << h.a.x << " " << h.a.y << " " << h.b.x << " " << h.b.y << endl;
  }
  cout << RV.size() << endl;
  for (Line v : RV) {
    cout << v.a.x << " " << v.a.y << " " << v.b.x << " " << v.b.y << endl;
  }
}