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 LL_INF = 1ll * INF * INF;
const int MAX_N = 1000 + 7;
template <typename T>
inline void addmod(T& a, const long long& b, const int& MOD = INF) {
  a = (a + b) % MOD;
  if (a < 0) a += MOD;
}
class HopcroftKarp {
 public:
  static const int MAX_V = 1e3 + 7;
  static const int MAX_E = 1e6 + 7;
  static const int nil = -1;
  int num_x, num_y, edge_count;
  int adj[MAX_E], next[MAX_E];
  int last[MAX_V], ptr[MAX_V], level[MAX_V], match_x[MAX_V], match_y[MAX_V];
  int visited[2][MAX_V];
  void init(int num_x_, int num_y_) {
    num_x = num_x_;
    num_y = num_y_;
    edge_count = 0;
    fill_n(last, num_x, nil);
    fill_n(match_x, num_x, nil);
    fill_n(match_y, num_y, nil);
  }
  void add_edge(int u, int v) {
    adj[edge_count] = v;
    next[edge_count] = last[u];
    last[u] = edge_count++;
  }
  int bfs() {
    static int queue_[MAX_V];
    int q_size = 0;
    for (int x = 0; x < num_x; x++) {
      if (match_x[x] != nil) {
        level[x] = 0;
      } else {
        level[x] = 1;
        queue_[q_size++] = x;
      }
    }
    int res = 0;
    for (int j = 0; j < q_size; ++j) {
      int x = queue_[j];
      for (int e = last[x]; e != nil; e = next[e]) {
        int y = adj[e];
        int u = match_y[y];
        if (u == nil) {
          res = 1;
        } else if (level[u] == 0) {
          level[u] = level[x] + 1;
          queue_[q_size++] = u;
        }
      }
    }
    return res;
  }
  bool dfs(int x) {
    for (int& e = ptr[x]; e != nil; e = next[e]) {
      int y = adj[e];
      int u = match_y[y];
      if (u == nil || (level[u] == level[x] + 1 && dfs(u))) {
        match_x[x] = y;
        match_y[y] = x;
        return true;
      }
    }
    return false;
  }
  int maximum_matching() {
    int res = 0;
    while (bfs()) {
      copy(last, last + num_x, ptr);
      for (int x = 0; x < num_x; x++)
        if (match_x[x] == nil) {
          res += dfs(x);
        }
    }
    return res;
  }
  void dfs(int u, bool right) {
    visited[right][u] = 1;
    if (!right) {
      for (int e = last[u]; e != nil; e = next[e]) {
        int v = adj[e];
        if (!visited[!right][v]) {
          dfs(v, !right);
        }
      }
    } else {
      int v = match_y[u];
      if (v != nil && !visited[!right][v]) {
        dfs(v, !right);
      }
    }
  }
  pair<vector<int>, vector<int>> min_cover() {
    fill_n(visited[0], num_x, 0);
    fill_n(visited[1], num_y, 0);
    for (int x = 0; x < num_x; x++)
      if (match_x[x] == nil && !visited[0][x]) {
        dfs(x, 0);
      }
    vector<int> lhs, rhs;
    for (int x = 0; x < num_x; x++)
      if (!visited[0][x]) {
        lhs.push_back(x);
      }
    for (int y = 0; y < num_y; y++)
      if (match_y[y] != nil && visited[1][y]) {
        rhs.push_back(y);
      }
    return {lhs, rhs};
  }
  pair<vector<int>, vector<int>> max_independent() {
    auto cover_vertexes = min_cover();
    cover_vertexes.first.push_back(num_x);
    cover_vertexes.second.push_back(num_y);
    auto get_unfilled = [](vector<int>& a) -> vector<int> {
      vector<int> ans;
      int i = 0;
      for (int x : a) {
        while (i < x) ans.push_back(i++);
        i++;
      }
      return ans;
    };
    return {get_unfilled(cover_vertexes.first),
            get_unfilled(cover_vertexes.second)};
  }
};
HopcroftKarp matching;
vector<int> rep_x, rep_y;
void normalize(int x[], int n, vector<int>& rep) {
  vector<int> val(x, x + n);
  sort(val.begin(), val.end());
  val.resize(unique(val.begin(), val.end()) - val.begin());
  for (int i = 0; i < n; ++i)
    x[i] = (int)(lower_bound(val.begin(), val.end(), x[i]) - val.begin());
  rep = val;
}
int n;
int x[MAX_N];
int y[MAX_N];
struct Node {
  int u, v, i, j;
  void print() {
    cout << rep_x[u] << ' ' << rep_y[v] << ' ' << rep_x[i] << ' ' << rep_y[j]
         << '\n';
  }
};
vector<int> point_rows[MAX_N];
vector<int> point_cols[MAX_N];
struct Segment {
  int pos;
  int left, right;
  int id;
};
int vertical[MAX_N][MAX_N];
int horizontal[MAX_N][MAX_N];
void solve() {
  cin >> n;
  matching.init(n, n);
  for (int i = (0), _b = (n); i < _b; ++i) cin >> x[i] >> y[i];
  normalize(x, n, rep_x);
  normalize(y, n, rep_y);
  for (int i = 0; i < n; ++i) {
    int u = x[i], v = y[i];
    point_rows[u].push_back(v);
    point_cols[v].push_back(u);
    vertical[u][v] = 1;
    horizontal[u][v] = 1;
  }
  for (int i = 0; i < n; ++i) {
    sort(point_cols[i].begin(), point_cols[i].end());
  }
  vector<Segment> left_seg;
  vector<Segment> right_seg;
  auto add_segment = [](vector<int>& a, int pos, vector<Segment>& segs) {
    sort(a.begin(), a.end());
    for (int i = 1; i < a.size(); ++i)
      if (a[i - 1] + 1 < a[i]) {
        segs.push_back({pos, a[i - 1] + 1, a[i] - 1, (int)(segs).size()});
      }
  };
  for (int i = 0; i < n; ++i)
    if (point_rows[i].size() > 1) {
      add_segment(point_rows[i], i, left_seg);
    }
  for (int i = 0; i < n; ++i)
    if (point_cols[i].size() > 1) {
      add_segment(point_cols[i], i, right_seg);
    }
  matching.init((int)(left_seg).size(), (int)(right_seg).size());
  for (const auto& lhs : left_seg)
    for (const auto& rhs : right_seg) {
      if (lhs.left <= rhs.pos && rhs.pos <= lhs.right && rhs.left <= lhs.pos &&
          lhs.pos <= rhs.right) {
        matching.add_edge(lhs.id, rhs.id);
      }
    }
  cerr << "matching.maximum_matching()"
       << ": " << (matching.maximum_matching()) << '\n';
  ;
  auto independent_vertexes = matching.max_independent();
  for (int x : independent_vertexes.first) {
    auto cur = left_seg[x];
    for (int j = cur.left; j <= cur.right; ++j) horizontal[cur.pos][j] = 1;
  }
  for (int x : independent_vertexes.second) {
    auto cur = right_seg[x];
    for (int i = cur.left; i <= cur.right; ++i) {
      vertical[i][cur.pos] = 1;
    }
  }
  vector<Node> ver;
  for (int j = 0; j < n; ++j) {
    for (int i = 0; i < n;) {
      if (!vertical[i][j]) {
        ++i;
        continue;
      };
      int k = i;
      while (vertical[k][j]) ++k;
      ver.push_back({i, j, k - 1, j});
      i = k;
    }
  }
  cout << ver.size() << '\n';
  for (auto v : ver) v.print();
  vector<Node> hor;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n;) {
      if (!horizontal[i][j]) {
        ++j;
        continue;
      };
      int k = j;
      while (horizontal[i][k]) ++k;
      hor.push_back({i, j, i, k - 1});
      j = k;
    }
  }
  cout << hor.size() << '\n';
  for (auto h : hor) h.print();
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  const bool multiple_test = false;
  int test = 1;
  if (multiple_test) cin >> test;
  for (int i = 0; i < test; ++i) {
    solve();
  }
}