#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int diri[4] = {-1, 0, 1, 0};
const int dirj[4] = {0, 1, 0, -1};
vector<pair<int, int> > vect;
set<pair<int, int> > result;
void dc(int e, int d) {
  if (e > d) return;
  int m = (e + d) / 2;
  int x = vect[m].first;
  int ee = m, dd = m;
  while (e < ee and vect[ee - 1].first == x) --ee;
  while (dd < d and vect[dd + 1].first == x) ++dd;
  for (int i = e; i < ee; ++i) result.insert(pair<int, int>(x, vect[i].second));
  for (int i = dd + 1; i <= d; ++i)
    result.insert(pair<int, int>(x, vect[i].second));
  dc(e, ee - 1);
  dc(dd + 1, d);
}
int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    pair<int, int> p;
    cin >> p.first >> p.second;
    result.insert(p);
  }
  vect = vector<pair<int, int> >(result.begin(), result.end());
  dc(0, n - 1);
  vect = vector<pair<int, int> >(result.begin(), result.end());
  int m = vect.size();
  cout << m << endl;
  for (int i = 0; i < m; ++i)
    cout << vect[i].first << " " << vect[i].second << endl;
}
