#include <bits/stdc++.h>
using namespace std;
const int maxl = 1000 * 10;
int n;
set<pair<int, int> > s;
vector<pair<int, int> > v;
inline void merge(int l, int r) {
  int mid = (l + r) >> 1;
  for (int i = l; i < r; i++) s.insert(make_pair(v[mid].first, v[i].second));
  return;
}
void solve(int l = 0, int r = n) {
  if (r - l <= 1) return;
  int mid = (l + r) >> 1;
  solve(l, mid);
  solve(mid, r);
  merge(l, r);
  return;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    s.insert(make_pair(x, y));
    v.push_back(make_pair(x, y));
  }
  sort(v.begin(), v.end());
  solve();
  cout << s.size() << endl;
  for (set<pair<int, int> >::iterator i = s.begin(); i != s.end(); i++)
    cout << (i->first) << " " << (i->second) << endl;
}
