#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 44;
const int X[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int Y[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int mod = 1e9 + 7;
const int INF = INT_MAX;
set<pair<int, int> > s;
int x[N], y[N], n;
vector<pair<int, int> > a;
void get(int l = 0, int r = n) {
  if (l >= r) return;
  int m = (l + r) / 2;
  for (int i = int(l); i < int(r); i++) {
    s.insert({a[m].first, a[i].second});
  }
  if (r - l == 1) return;
  get(l, m);
  get(m, r);
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = int(0); i < int(n); i++) {
    cin >> x[i] >> y[i];
    x[i]--, y[i]--;
    a.push_back({x[i], y[i]});
  }
  sort(a.begin(), a.end());
  get();
  cout << s.size() << "\n";
  set<pair<int, int> >::iterator it = s.begin();
  for (int i = int(0); i < int(s.size()); i++) {
    cout << (*it).first + 1 << " " << (*it).second + 1 << "\n";
    it++;
  }
}
