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>
#pragma comment(linker, "/STACK:512000000")
using namespace std;
using li = long long;
using ld = long double;
void solve(bool);
void precalc();
clock_t start;
int main() {
  start = clock();
  int t = 1;
  cout.sync_with_stdio(0);
  cin.tie(0);
  cout.precision(20);
  cout << fixed;
  precalc();
  while (t--) {
    solve(true);
  }
  cout.flush();
  return 0;
}
template <typename T>
T binpow(T q, T w, T mod) {
  if (!w) return 1 % mod;
  if (w & 1) return q * 1LL * binpow(q, w - 1, mod) % mod;
  return binpow(q * 1LL * q % mod, w / 2, mod);
}
template <typename T>
T gcd(T q, T w) {
  while (w) {
    q %= w;
    swap(q, w);
  }
  return q;
}
template <typename T>
T lcm(T q, T w) {
  return q / gcd(q, w) * w;
}
template <typename T>
void make_unique(vector<T>& vec) {
  sort(vec.begin(), vec.end());
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
}
template <typename T>
void relax_min(T& cur, T val) {
  cur = min(cur, val);
}
template <typename T>
void relax_max(T& cur, T val) {
  cur = max(cur, val);
}
mt19937 rng(
    (unsigned long long)chrono::steady_clock::now().time_since_epoch().count());
void precalc() {}
vector<vector<int>> g;
vector<int> used;
int TIMER = 1;
vector<int> mt;
bool dfs(int v) {
  if (used[v] == TIMER) {
    return false;
  }
  used[v] = TIMER;
  for (int to : g[v]) {
    if (mt[to] == -1) {
      mt[to] = v;
      return true;
    }
  }
  for (int to : g[v]) {
    if (dfs(mt[to])) {
      mt[to] = v;
      return true;
    }
  }
  return false;
}
vector<char> in_right, in_left;
void dfs_set(int v) {
  for (int to : g[v]) {
    if (in_right[to]) {
      in_right[to] = false;
      assert(mt[to] != -1);
      in_left[mt[to]] = true;
      dfs_set(mt[to]);
    }
  }
}
void solve(__attribute__((unused)) bool read) {
  g.clear();
  used.clear();
  mt.clear();
  in_left.clear();
  in_right.clear();
  int MAX_COORD = (int)1e5;
  TIMER = 1;
  int N;
  if (read) {
    cin >> N;
  } else {
    N = 1000;
  }
  vector<vector<int>> coords(2);
  vector<vector<int>> pts(N);
  set<vector<int>> have;
  for (int i = 0; i < N; ++i) {
    auto& cur_pt = pts[i];
    cur_pt.resize(2);
    if (read) {
      for (int j = 0; j < 2; ++j) {
        cin >> cur_pt[j];
      }
    } else {
      do {
        for (int j = 0; j < 2; ++j) {
          cur_pt[j] = rand() % MAX_COORD + 1;
        }
      } while (have.count(cur_pt));
      have.insert(cur_pt);
    }
    for (int j = 0; j < 2; ++j) {
      coords[j].push_back(cur_pt[j]);
    }
  }
  for (int i = 0; i < 2; ++i) {
    make_unique(coords[i]);
  }
  int n = coords[0].size(), m = coords[1].size();
  vector<vector<int>> matrix(n, vector<int>(m));
  for (auto& pt : pts) {
    for (int j = 0; j < 2; ++j) {
      pt[j] = lower_bound(coords[j].begin(), coords[j].end(), pt[j]) -
              coords[j].begin();
    }
    matrix[pt[0]][pt[1]] = 1;
  }
  vector<vector<int>> down_vs = matrix;
  vector<vector<int>> up_vs = matrix;
  for (int j = 0; j < m; ++j) {
    for (int i = n - 2; i >= 0; --i) {
      down_vs[i][j] += down_vs[i + 1][j];
    }
    for (int i = 1; i < n; ++i) {
      up_vs[i][j] += up_vs[i - 1][j];
    }
  }
  vector<vector<vector<int>>> vertices(2);
  vector<vector<vector<int>>> answers(2);
  for (int i = 0; i < 2; ++i) {
    answers[i].resize(coords[i].size());
  }
  vector<int> cur_vertex(m, -1);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (matrix[i][j]) {
        cur_vertex[j] = -1;
        answers[0][i].push_back(j);
        answers[1][j].push_back(i);
      } else {
        if (cur_vertex[j] != -1) {
          vertices[1][cur_vertex[j]].back() = i;
        } else if (up_vs[i][j] > 0 && down_vs[i][j] > 0) {
          cur_vertex[j] = vertices[1].size();
          vertices[1].push_back({j, i, i});
        }
      }
    }
    int cnt = 0;
    for (int j = 0; j < m; ++j) {
      if (matrix[i][j]) {
        ++cnt;
        continue;
      }
      if (cnt == 0) {
        continue;
      }
      int r = j;
      while (r < m && matrix[i][r] == 0) {
        ++r;
      }
      if (r == m) {
        continue;
      }
      vertices[0].push_back({i, j, r - 1});
      g.push_back({});
      for (int z = j; z < r; ++z) {
        if (cur_vertex[z] != -1) {
          g.back().push_back(cur_vertex[z]);
        }
      }
      j = r - 1;
    }
  }
  mt.assign(vertices[1].size(), -1);
  used.assign(vertices[0].size(), 0);
  int matching = 0;
  for (int i = 0; i < vertices[0].size(); ++i) {
    if (dfs(i)) {
      ++TIMER;
      ++matching;
    }
  }
  vector<bool> in_match(vertices[0].size(), false);
  for (auto x : mt) {
    if (x != -1) {
      in_match[x] = true;
    }
  }
  in_left.assign(vertices[0].size(), true);
  in_right.assign(vertices[1].size(), true);
  for (int i = 0; i < vertices[0].size(); ++i) {
    if (in_match[i]) {
      in_left[i] = false;
    }
  }
  for (int i = 0; i < vertices[0].size(); ++i) {
    if (!in_match[i]) {
      dfs_set(i);
    }
  }
  int cnt_ans = 0;
  for (int i = 0; i < vertices[0].size(); ++i) {
    if (in_left[i]) {
      ++cnt_ans;
    }
  }
  for (int i = 0; i < vertices[1].size(); ++i) {
    if (in_right[i]) {
      ++cnt_ans;
    }
  }
  assert(cnt_ans + matching == vertices[0].size() + vertices[1].size());
  for (int i = 0; i < vertices[0].size(); ++i) {
    if (in_left[i]) {
      for (int to : g[i]) {
        assert(!in_right[to]);
      }
    }
  }
  for (int w = 0; w < 2; ++w) {
    auto& vs = vertices[w];
    auto& in_par = (w == 0 ? in_left : in_right);
    for (int i = 0; i < vs.size(); ++i) {
      if (in_par[i]) {
        int x = vs[i][0];
        for (int y = vs[i][1]; y <= vs[i][2]; ++y) {
          answers[w][x].push_back(y);
        }
      }
    }
  }
  vector<vector<vector<int>>> results(2);
  for (int w = 0; w < 2; ++w) {
    for (int i = 0; i < coords[w].size(); ++i) {
      auto& vec = answers[w][i];
      sort(vec.begin(), vec.end());
      for (int j = 0; j < vec.size(); ++j) {
        int r = j;
        while (r + 1 < vec.size() && vec[r + 1] == vec[r] + 1) {
          ++r;
        }
        results[w].push_back(
            {coords[w][i], coords[w ^ 1][vec[j]], coords[w ^ 1][vec[r]]});
        j = r;
      }
    }
  }
  if (read) {
    for (int ww = 0; ww < 2; ++ww) {
      int w = ww ^ 1;
      cout << results[w].size() << "\n";
      for (auto& vec : results[w]) {
        if (w == 0) {
          cout << vec[0] << " " << vec[1] << " " << vec[0] << " " << vec[2]
               << "\n";
        } else {
          cout << vec[1] << " " << vec[0] << " " << vec[2] << " " << vec[0]
               << "\n";
        }
      }
    }
  } else {
    cout << "ok\n";
  }
}