#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 5;
vector<int> compress, T[maxn];
unordered_set<int> seg[4 * maxn];
set<pair<int, int> > S;
int x[maxn], y[maxn];
unordered_map<int, int> M;
void build(int id, int L, int R) {
  if (R == L + 1) {
    for (auto t : T[L]) seg[id].insert(t);
    return;
  }
  int mid = (L + R) / 2;
  build(2 * id + 0, L, mid);
  build(2 * id + 1, mid, R);
  for (auto t : seg[2 * id + 0]) seg[id].insert(t);
  for (auto t : seg[2 * id + 1]) seg[id].insert(t);
  for (auto t : seg[id]) S.insert(pair<int, int>(compress[mid], t));
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i];
    S.insert(pair<int, int>(x[i], y[i]));
    compress.push_back(x[i]);
  }
  sort(compress.begin(), compress.end());
  compress.resize(unique(compress.begin(), compress.end()) - compress.begin());
  int sz = compress.size();
  for (int i = 0; i < sz; i++) M[compress[i]] = i;
  for (int i = 0; i < n; i++) T[M[x[i]]].push_back(y[i]);
  build(1, 0, sz);
  cout << S.size() << '\n';
  for (auto t : S) cout << t.first << ' ' << t.second << '\n';
}
