#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    s = s * 10 + ch - '0';
    ch = getchar();
  }
  return s * w;
}
pair<int, int> p[200005];
set<pair<int, int> > s;
void solve(int l, int r) {
  if (l >= r) return;
  int mid = (l + r) >> 1;
  for (int i = l; i <= r; i++)
    s.insert(pair<int, int>(p[mid].first, p[i].second));
  solve(l, mid);
  solve(mid + 1, r);
  return;
}
int n;
void init() {
  n = read();
  for (int i = 1; i <= n; i++) {
    p[i].first = read();
    p[i].second = read();
    s.insert(p[i]);
  }
  sort(p + 1, p + n + 1);
  return;
}
void solv() {
  solve(1, n);
  printf("%d\n", (int)s.size());
  for (auto i = s.begin(); i != s.end(); i++) {
    printf("%d %d\n", i->first, i->second);
  }
  return;
}
int main() {
  init();
  solv();
  return 0;
}
