#include <bits/stdc++.h>
using namespace std;
const int N = 200004;
int n, m;
struct node {
  int x, y;
  node() {}
  node(int xx, int yy) {
    x = xx;
    y = yy;
  }
} a[N];
pair<int, int> b[N];
bool cmp1(node p, node q) {
  if (p.x == q.x)
    return p.y < q.y;
  else
    return p.x < q.x;
}
bool cmp2(node p, node q) {
  if (p.y == q.y) return p.x < q.x;
  return p.y < q.y;
}
void solve(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  solve(l, mid);
  solve(mid + 1, r);
  for (int i = l; i < mid; i++) a[++m] = node(a[mid].x, a[i].y);
  for (int i = mid + 1; i <= r; i++) a[++m] = node(a[mid].x, a[i].y);
}
int main() {
  scanf("%d", &n);
  m = n;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", &a[i].x, &a[i].y);
  }
  sort(a + 1, a + n + 1, cmp1);
  solve(1, n);
  for (int i = 1; i <= m; i++) b[i] = make_pair(a[i].x, a[i].y);
  sort(b + 1, b + m + 1);
  n = unique(b + 1, b + m + 1) - b - 1;
  printf("%d\n", n);
  for (int i = 1; i <= n; i++) printf("%d %d\n", b[i].first, b[i].second);
  return 0;
}
