#include <bits/stdc++.h>
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int MOD = mod - 1;
const int inf = 0x3f3f3f3f;
const double PI = acos(-1.0);
const double eps = 1e-10;
using namespace std;
pair<int, int> a[10005];
set<pair<int, int> > s;
void dfs(int l, int r) {
  int mid = (l + r) >> 1;
  int x = a[mid].first;
  for (int i = l; i <= r; i++) {
    s.insert(pair<int, int>(x, a[i].second));
  }
  if (l < mid) {
    dfs(l, mid - 1);
  }
  if (r > mid) {
    dfs(mid + 1, r);
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i].first), scanf("%d", &a[i].second);
  }
  sort(a, a + n);
  for (int i = 0; i < n; i++) s.insert(a[i]);
  dfs(0, n - 1);
  printf("%d\n", s.size());
  for (auto &it : s) {
    printf("%d %d\n", it.first, it.second);
  }
}
