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;
const int INF = 1e9 + 7;
const long long INFL = 1e18 + 123;
const double PI = atan2(0, -1);
mt19937 tw(960172);
long long rnd(long long x, long long y) {
  static uniform_int_distribution<long long> d;
  return d(tw) % (y - x + 1) + x;
}
struct edge {
  int f, c;
  edge() : f(0), c(0) {}
  edge(int _c) : f(0), c(_c) {}
};
vector<edge> edges;
vector<vector<pair<int, int>>> graph;
int add_node() {
  graph.push_back({});
  return ((int)(graph).size()) - 1;
}
void add_edge(int a, int b, int c) {
  graph[a].push_back({b, ((int)(edges).size())});
  edges.push_back(edge(c));
  graph[b].push_back({a, ((int)(edges).size())});
  edges.push_back(edge(0));
}
vector<int> qu;
vector<int> vcnt;
vector<int> dist;
int build_layers(int s, int t) {
  int l = 0, r = 0;
  qu[r++] = s;
  fill(dist.begin(), dist.end(), INF);
  dist[s] = 0;
  fill(vcnt.begin(), vcnt.end(), 0);
  while (l < r) {
    int v = qu[l++];
    for (pair<int, int> to : graph[v]) {
      if (edges[to.second].f < edges[to.second].c &&
          dist[to.first] > dist[v] + 1) {
        dist[to.first] = dist[v] + 1;
        qu[r++] = to.first;
      }
    }
  }
  if (dist[t] == INF) {
    return 0;
  }
  return 1;
}
int push_flow(int v, int t, int f) {
  if (v == t) {
    return f;
  }
  while (vcnt[v] < ((int)(graph[v]).size())) {
    auto& to = graph[v][vcnt[v]];
    if (edges[to.second].f < edges[to.second].c &&
        dist[to.first] == dist[v] + 1) {
      int tmp = push_flow(to.first, t,
                          min(f, edges[to.second].c - edges[to.second].f));
      if (tmp) {
        edges[to.second].f += tmp;
        edges[to.second ^ 1].f -= tmp;
        return tmp;
      }
    }
    vcnt[v]++;
  }
  return 0;
}
void solve() {
  int n;
  cin >> n;
  map<int, vector<pair<int, int>>> by_x, by_y;
  vector<pair<int, int>> coords;
  for (int i = 0; i < n; ++i) {
    int x, y;
    cin >> x >> y;
    coords.push_back({x, y});
    by_x[x].push_back({y, i});
    by_y[y].push_back({x, i});
  }
  vector<pair<int, int>> hor_segs, ver_segs;
  for (auto& p : by_x) {
    sort(p.second.begin(), p.second.end());
    for (int i = 0; i < ((int)(p.second).size()) - 1; ++i) {
      ver_segs.push_back({p.second[i].second, p.second[i + 1].second});
    }
  }
  for (auto& p : by_y) {
    sort(p.second.begin(), p.second.end());
    for (int i = 0; i < ((int)(p.second).size()) - 1; ++i) {
      hor_segs.push_back({p.second[i].second, p.second[i + 1].second});
    }
  }
  int s = add_node();
  int t = add_node();
  vector<int> left_nodes, right_nodes;
  for (int i = 0; i < ((int)(ver_segs).size()); ++i) {
    left_nodes.push_back(add_node());
    add_edge(s, left_nodes.back(), 1);
  }
  for (int i = 0; i < ((int)(hor_segs).size()); ++i) {
    right_nodes.push_back(add_node());
    add_edge(right_nodes.back(), t, 1);
  }
  for (int i = 0; i < ((int)(ver_segs).size()); ++i) {
    for (int j = 0; j < ((int)(hor_segs).size()); ++j) {
      int a, b, c, d;
      tie(a, b) = ver_segs[i];
      tie(c, d) = hor_segs[j];
      if (coords[c].first < coords[a].first &&
          coords[a].first < coords[d].first &&
          coords[a].second < coords[c].second &&
          coords[c].second < coords[b].second) {
        add_edge(left_nodes[i], right_nodes[j], 1);
      }
    }
  }
  int f = 0;
  qu = dist = vcnt = vector<int>(((int)(graph).size()));
  while (true) {
    if (!build_layers(s, t)) {
      break;
    }
    while (true) {
      int tmp = push_flow(s, t, INF);
      if (!tmp) {
        break;
      }
      f += tmp;
    }
  }
  queue<int> qu;
  vector<bool> used(((int)(graph).size()));
  for (pair<int, int> to : graph[s]) {
    if (!edges[to.second].f) {
      qu.push(to.first);
      used[to.first] = true;
    }
  }
  while (((int)(qu).size())) {
    int v = qu.front();
    qu.pop();
    for (pair<int, int> to : graph[v]) {
      if (to.first != s && to.first != t &&
          edges[to.second].f < edges[to.second].c) {
        if (!used[to.first]) {
          used[to.first] = true;
          qu.push(to.first);
        }
      }
    }
  }
  set<pair<int, int>> take_ver, take_hor;
  for (int i = 2; i < ((int)(graph).size()); ++i) {
    if (i < 2 + ((int)(left_nodes).size())) {
      if (used[i]) {
        take_ver.insert(ver_segs[i - 2]);
      }
    } else {
      if (!used[i]) {
        take_hor.insert(hor_segs[i - 2 - ((int)(left_nodes).size())]);
      }
    }
  }
  vector<pair<pair<int, int>, pair<int, int>>> ans;
  for (auto& p : by_y) {
    pair<int, int> from = {p.second.front().first, p.first};
    for (int i = 0; i < ((int)(p.second).size()) - 1; ++i) {
      if (!take_hor.count({p.second[i].second, p.second[i + 1].second})) {
        ans.push_back({from, {p.second[i].first, p.first}});
        from = {p.second[i + 1].first, p.first};
      }
    }
    ans.push_back({from, {p.second.back().first, p.first}});
  }
  cout << ((int)(ans).size()) << "\n";
  for (auto p : ans) {
    cout << p.first.first << " " << p.first.second << " " << p.second.first
         << " " << p.second.second << "\n";
  }
  ans = {};
  for (auto& p : by_x) {
    pair<int, int> from = {p.first, p.second.front().first};
    for (int i = 0; i < ((int)(p.second).size()) - 1; ++i) {
      if (!take_ver.count({p.second[i].second, p.second[i + 1].second})) {
        ans.push_back({from, {p.first, p.second[i].first}});
        from = {p.first, p.second[i + 1].first};
      }
    }
    ans.push_back({from, {p.first, p.second.back().first}});
  }
  cout << ((int)(ans).size()) << "\n";
  for (auto p : ans) {
    cout << p.first.first << " " << p.first.second << " " << p.second.first
         << " " << p.second.second << "\n";
  }
}
int main() {
  cerr << fixed << setprecision(15);
  cout << fixed << setprecision(15);
  ios::sync_with_stdio(false);
  int tests = 1;
  for (int it = 1; it <= tests; ++it) {
    solve();
  }
  return 0;
}