#include <bits/stdc++.h>
long long read() {
  long long x = 0, f = 1;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return f * x;
}
long long max(long long a, long long b) { return a > b ? a : b; }
void umax(long long& a, long long t) {
  if (t > a) a = t;
}
void umin(long long& a, long long t) {
  if (t < a) a = t;
}
std::pair<long long, long long> a[200011], tmp[200011];
std::set<std::pair<long long, long long> > s;
long long n;
void solve(long long l, long long r) {
  if (l == r) return;
  long long mid = (l + r) >> 1, split_line = a[mid + 1].first;
  solve(l, mid), solve(mid + 1, r);
  for (long long i = l; i <= r; ++i)
    s.insert(std::pair<long long, long long>(split_line, a[i].second));
}
int main() {
  n = read();
  for (long long i = 1; i <= n; ++i)
    a[i].first = read(), a[i].second = read(), s.insert(a[i]);
  std::sort(a + 1, a + n + 1);
  solve(1, n);
  std::cout << s.size() << '\n';
  for (auto x : s) printf("%lld %lld\n", x.first, x.second);
  return 0;
}
