#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e4 + 10;
pair<int, int> point[maxn];
set<pair<int, int> > all;
int n;
void dfs(int l, int r) {
  int mid = (l + r) >> 1, mid_x = point[mid].first;
  for (int i = l; i <= r; i++) all.insert(make_pair(mid_x, point[i].second));
  if (l < mid) dfs(l, mid - 1);
  if (mid < r) dfs(mid + 1, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) scanf("%d%d", &point[i].first, &point[i].second);
  sort(point + 1, point + 1 + n);
  dfs(1, n);
  int p = all.size();
  printf("%d\n", p);
  auto it = all.begin();
  for (; it != all.end(); ++it) printf("%d %d\n", it->first, it->second);
  return 0;
}
