#include <bits/stdc++.h>
using namespace std;
int cond = 1;
const int M = 201013;
int m;
pair<int, int> t[M];
set<pair<int, int> > x;
void go(int a, int b) {
  if (a > b) return;
  if (a == b) {
    x.insert(t[a]);
    return;
  }
  int s = (a + b) / 2;
  int A = a;
  while (t[A].first < t[s].first) A++;
  go(a, A - 1);
  int B = b;
  while (t[B].first > t[s].first) B--;
  go(B + 1, b);
  for (typeof(A) i = (A); i <= (B); ++i) x.insert(t[i]);
  for (typeof(a) i = (a); i <= (A - 1); ++i)
    x.insert(make_pair(t[s].first, t[i].second));
  for (typeof(B + 1) i = (B + 1); i <= (b); ++i)
    x.insert(make_pair(t[s].first, t[i].second));
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < (n); i++) scanf("%d %d", &t[i].first, &t[i].second);
  sort(t, t + n);
  go(0, n - 1);
  printf("%d\n", ((int)((x).size())));
  for (typeof((x).begin()) i = ((x).begin()); i != (x).end(); ++i)
    printf("%d %d\n", i->first, i->second);
  return 0;
}
