#include <bits/stdc++.h>
using namespace std;
void opting() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
}
int inp() {
  int x;
  cin >> x;
  return x;
}
const int maxn = 1e4 + 69;
vector<int> x_point;
map<int, vector<int> > y_point;
void solve(int l, int r) {
  if (r - l <= 1) return;
  int mid = (l + r) >> 1;
  solve(l, mid);
  solve(mid, r);
  for (int a = l; a < r; a++)
    if (a == mid)
      continue;
    else
      for (auto Y : y_point[x_point[a]]) y_point[x_point[mid]].push_back(Y);
  int X = x_point[mid];
  sort((y_point[X]).begin(), (y_point[X]).end());
  y_point[X].resize(unique((y_point[X]).begin(), (y_point[X]).end()) -
                    y_point[X].begin());
}
void show() {
  int ans = 0;
  for (auto x : x_point) ans += y_point[x].size();
  cout << ans << '\n';
  for (auto x : x_point)
    for (auto y : y_point[x]) cout << x << ' ' << y << '\n';
}
void input() {
  int n = inp();
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    x_point.push_back(x);
    y_point[x].push_back(y);
  }
  sort((x_point).begin(), (x_point).end());
  x_point.resize(unique((x_point).begin(), (x_point).end()) - x_point.begin());
}
int main() {
  opting();
  input();
  solve(0, x_point.size());
  show();
}
