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;
namespace {
template <class Flow = int, template <class> class Alloc = allocator>
class Dinics {
 public:
  struct Edge {
    int to;
    Flow cap;
  };
  using EdgeList = vector<int, Alloc<int>>;
  vector<EdgeList, Alloc<EdgeList>> adj_;
  vector<int, Alloc<int>> dist_, cur_edge_;
  vector<Edge, Alloc<Edge>> edges_;
  queue<int, deque<int, Alloc<int>>> que_;
  int sink_;
  Flow Augment(int at, const Flow& flow) {
    if (at == sink_) return flow;
    Flow res = 0;
    for (auto& index = cur_edge_[at]; index < static_cast<int>(adj_[at].size());
         ++index) {
      const auto edge_index = adj_[at][index];
      auto& edge = edges_[edge_index];
      if (0 != edge.cap and 1 + dist_[at] == dist_[edge.to]) {
        const auto& aug = Augment(edge.to, min(flow - res, edge.cap));
        res += aug;
        edge.cap -= aug;
        edges_[edge_index ^ 1].cap += aug;
        if (res == flow) break;
      }
    }
    if (res == 0) dist_[at] = 0;
    return res;
  }

 public:
  Dinics(int num_vertices, int edges_estimate = 0)
      : adj_(num_vertices), dist_(num_vertices), cur_edge_(num_vertices) {
    edges_.reserve(2 * edges_estimate);
  }
  int AddEdge(int from, int to, const Flow& cap) {
    const auto res = static_cast<int>(edges_.size());
    adj_[from].push_back(res);
    edges_.push_back({to, cap});
    adj_[to].push_back(static_cast<int>(edges_.size()));
    edges_.push_back({from, 0});
    return res;
  }
  Flow Run(int source, int sink) {
    sink_ = sink;
    Flow res = 0;
    while (true) {
      fill(dist_.begin(), dist_.end(), 0);
      fill(cur_edge_.begin(), cur_edge_.end(), 0);
      while (not que_.empty()) que_.pop();
      que_.push(source);
      dist_[source] = 1;
      while (not que_.empty() and 0 == dist_[sink]) {
        const auto at = que_.front();
        que_.pop();
        for (const auto& edge_index : adj_[at]) {
          const auto& edge = edges_[edge_index];
          if (0 != edge.cap and 0 == dist_[edge.to]) {
            dist_[edge.to] = 1 + dist_[at];
            que_.push(edge.to);
          }
        }
      }
      if (0 == dist_[sink]) break;
      res += Augment(source, numeric_limits<Flow>::max());
    }
    return res;
  }
  set<int> GetCutEdges(int src) {
    set<int> res;
    while (not que_.empty()) que_.pop();
    vector<bool> vis(adj_.size());
    que_.push(src);
    vis[src] = true;
    while (not que_.empty()) {
      const auto at = que_.front();
      que_.pop();
      for (const auto& edge_index : adj_[at]) {
        const auto& edge = edges_[edge_index];
        if (edge.cap > 0 and !vis[edge.to]) {
          que_.push(edge.to);
          vis[edge.to] = true;
        }
      }
    }
    for (int v = 0; v < (int)adj_.size(); ++v)
      if (vis[v]) {
        for (const auto& edge_index : adj_[v]) {
          const auto& edge = edges_[edge_index];
          if (not vis[edge.to]) res.insert(edge_index);
        }
      }
    return res;
  }
  Edge& GetEdge(int edge_index) { return edges_[edge_index]; }
  int GetNumEdges() const { return static_cast<int>(edges_.size()); }
  void ResetEdges() {
    for (int edge_index = 0; edge_index < GetNumEdges(); edge_index += 2) {
      edges_[edge_index].cap += edges_[edge_index ^ 1].cap;
      edges_[edge_index ^ 1].cap = 0;
    }
  }
};
template <int MAX_VERTICES, int MAX_EDGES>
struct BipartiteMatcher {
  const int NIL = -1;
  static constexpr int INF = numeric_limits<int>::max() / 2;
  int match_left[MAX_VERTICES], match_right[MAX_VERTICES], edge_count,
      left_count, right_count;
  int head[MAX_VERTICES], to[MAX_EDGES], pred[MAX_EDGES];
  int dist[MAX_VERTICES], queue[MAX_VERTICES];
  void Init(int boys, int girls) {
    fill(head, head + boys, -1);
    edge_count = 0;
    left_count = boys;
    right_count = girls;
  }
  void AddEdge(int boy, int girl) {
    to[edge_count] = girl;
    pred[edge_count] = head[boy];
    head[boy] = edge_count++;
  }
  bool BreadthFirstSearch() {
    int qf = 0, qb = 0;
    for (int v = 0; v < left_count; ++v)
      if (match_left[v] == NIL)
        dist[queue[qb++] = v] = 0;
      else
        dist[v] = INF;
    bool found = false;
    for (; qf < qb; ++qf)
      for (int at = queue[qf], e = head[at]; ~e; e = pred[e])
        if (match_right[to[e]] == NIL)
          found = true;
        else if (dist[match_right[to[e]]] == INF)
          dist[queue[qb++] = match_right[to[e]]] = dist[at] + 1;
    return found;
  }
  bool DepthFirstSearch(int at) {
    for (int e = head[at]; ~e; e = pred[e])
      if (match_right[to[e]] == -1 or
          (dist[match_right[to[e]]] == dist[at] + 1 and
           DepthFirstSearch(match_right[to[e]]))) {
        match_left[at] = to[e];
        match_right[to[e]] = at;
        return true;
      }
    dist[at] = INF;
    return false;
  }
  int Go() {
    fill(match_left, match_left + left_count, NIL);
    fill(match_right, match_right + right_count, NIL);
    int matches = 0;
    for (int v = 0; v < left_count; ++v)
      for (int e = head[v]; ~e; e = pred[e])
        if (match_right[to[e]] == NIL) {
          match_right[to[e]] = v;
          match_left[v] = to[e];
          ++matches;
          break;
        }
    while (BreadthFirstSearch())
      for (int v = 0; v < left_count; ++v)
        if (match_left[v] == NIL and dist[v] != INF and DepthFirstSearch(v))
          ++matches;
    return matches;
  }
  pair<vector<int>, vector<int>> GetVertexCover() {
    vector<int> lefts, rights;
    int qf = 0, qb = 0;
    for (int v = 0; v < left_count; ++v) {
      if (match_left[v] == NIL) {
        queue[qb++] = v;
        dist[v] = 0;
      } else {
        dist[v] = INF;
      }
    }
    while (qf < qb) {
      const int at = queue[qf++];
      for (int e = head[at]; ~e; e = pred[e]) {
        if (dist[match_right[to[e]]] == INF) {
          rights.push_back(to[e]);
          dist[queue[qb++] = match_right[to[e]]] = 0;
        }
      }
    }
    sort(rights.begin(), rights.end());
    for (int v = 0; v < left_count; ++v)
      if (dist[v] == INF) lefts.push_back(v);
    for (int v = 0; v < left_count; ++v) {
      if (head[v] == -1) continue;
      if (binary_search(lefts.begin(), lefts.end(), v)) continue;
      for (int e = head[v]; ~e; e = pred[e])
        assert(binary_search(rights.begin(), rights.end(), to[e]));
    }
    return {lefts, rights};
  }
};
BipartiteMatcher<1024, 1 << 20> bpm;
struct Seg {
  int same, fr, to;
};
void Solve(int) {
  int n;
  cin >> n;
  vector<pair<int, int>> pts(n);
  for (auto& p : pts) cin >> p.first >> p.second;
  map<int, vector<int>> by_x, by_y;
  for (auto& p : pts) {
    by_x[p.first].push_back(p.second);
    by_y[p.second].push_back(p.first);
  }
  vector<Seg> verts, horts;
  for (auto& entry : by_x) {
    const int x = entry.first;
    auto& ys = entry.second;
    sort(ys.begin(), ys.end());
    for (int i = 1, __i = ((int)(ys.size())); i < __i; ++i) {
      verts.push_back({x, ys[i - 1], ys[i]});
    }
  }
  for (auto& entry : by_y) {
    const int y = entry.first;
    auto& xs = entry.second;
    sort(xs.begin(), xs.end());
    for (int i = 1, __i = ((int)(xs.size())); i < __i; ++i) {
      horts.push_back({y, xs[i - 1], xs[i]});
    }
  }
  const int num_verts = ((int)(verts.size()));
  Dinics<> net(num_verts + ((int)(horts.size())) + 2);
  const int src = num_verts + ((int)(horts.size()));
  const int sink = src + 1;
  for (int i = 0, __i = ((int)(verts.size())); i < __i; ++i)
    for (int j = 0, __j = ((int)(horts.size())); j < __j; ++j) {
      const auto& hort = horts[j];
      const int x = verts[i].same;
      const int y = hort.same;
      if (hort.fr < x and x < hort.to and verts[i].fr < y and y < verts[i].to) {
        net.AddEdge(i, num_verts + j, 1e8);
      }
    }
  vector<int> src_idx, sink_idx;
  for (int i = 0, __i = ((int)(verts.size())); i < __i; ++i)
    src_idx.push_back(net.AddEdge(src, i, 1));
  for (int j = 0, __j = ((int)(horts.size())); j < __j; ++j)
    sink_idx.push_back(net.AddEdge(j + num_verts, sink, 1));
  const auto max_flow = net.Run(src, sink);
  bpm.Go();
  const auto cut_edges = net.GetCutEdges(src);
  vector<tuple<int, int, int, int>> res_verts, res_horts;
  int idx = 0;
  for (auto& entry : by_x) {
    const int x = entry.first;
    auto& ys = entry.second;
    int y1 = ys.front();
    for (int i = 1, __i = ((int)(ys.size())); i < __i; ++i) {
      if (cut_edges.count(src_idx[idx++])) {
        res_verts.emplace_back(x, y1, x, ys[i - 1]);
        y1 = ys[i];
      }
    }
    res_verts.emplace_back(x, y1, x, ys.back());
  }
  idx = 0;
  for (auto& entry : by_y) {
    const int y = entry.first;
    auto& xs = entry.second;
    int x1 = xs.front();
    for (int i = 1, __i = ((int)(xs.size())); i < __i; ++i) {
      if (cut_edges.count(sink_idx[idx++])) {
        res_horts.emplace_back(x1, y, xs[i - 1], y);
        x1 = xs[i];
      }
    }
    res_horts.emplace_back(x1, y, xs.back(), y);
  }
  cout << ((int)(res_horts.size())) << endl;
  for (auto& r : res_horts) {
    cout << get<0>(r) << ' ' << get<1>(r) << ' ' << get<2>(r) << ' '
         << get<3>(r) << endl;
  }
  cout << ((int)(res_verts.size())) << endl;
  for (auto& r : res_verts) {
    cout << get<0>(r) << ' ' << get<1>(r) << ' ' << get<2>(r) << ' '
         << get<3>(r) << endl;
  }
}
void Init() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
}
}  // namespace
int32_t main() {
  Init();
  int tests = 1;
  for (int test = 1, __test = tests + 1; test < __test; ++test) Solve(test);
  return 0;
}