#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 50;
int n, cnt;
pair<int, int> poi[maxn], A[maxn];
void solve(int l, int r) {
  if (l > r) return;
  int mid = (l + r) >> 1;
  for (int i = l; i <= r; i++)
    poi[++cnt] = (pair<int, int>){A[mid].first, A[i].second};
  solve(l, mid - 1);
  solve(mid + 1, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &A[i].first, &A[i].second);
  sort(A + 1, A + 1 + n);
  solve(1, n);
  sort(poi + 1, poi + 1 + cnt);
  cnt = unique(poi + 1, poi + 1 + cnt) - poi - 1;
  printf("%d\n", cnt);
  for (int i = 1; i <= cnt; i++) printf("%d %d\n", poi[i].first, poi[i].second);
  return 0;
}
