#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y;
} e[100010], ans[1000010], print[1000010];
int n, cnt, tot;
bool cmp(node a, node b) {
  if (a.x == b.x) return a.y < b.y;
  return a.x < b.x;
}
void solve(int l, int r) {
  if (l == r) ans[++cnt] = e[l];
  if (l >= r) return;
  int mid = (l + r) >> 1;
  solve(l, mid - 1);
  solve(mid + 1, r);
  for (int i = l; i <= r; i++) {
    node temp;
    temp.x = e[mid].x;
    temp.y = e[i].y;
    ans[++cnt] = temp;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &e[i].x, &e[i].y);
  sort(e + 1, e + 1 + n, cmp);
  solve(1, n);
  sort(ans + 1, ans + 1 + cnt, cmp);
  print[++tot] = ans[1];
  for (int i = 2; i <= cnt; i++)
    if (ans[i].x != ans[i - 1].x || ans[i].y != ans[i - 1].y)
      print[++tot] = ans[i];
  printf("%d\n", tot);
  for (int i = 1; i <= tot; i++) printf("%d %d\n", print[i].x, print[i].y);
  return 0;
}
