#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 5;
int n;
struct Point {
  int x, y;
  Point(int _x = 0, int _y = 0) : x(_x), y(_y) {}
  bool operator<(const Point &a) const {
    if (x == a.x) return y < a.y;
    return x < a.x;
  }
} p[N << 1];
set<Point> out;
void dfs(int l, int r) {
  if (l >= r) return;
  int mid = l + (r - l) / 2;
  for (int i = l; i <= r; ++i) {
    out.insert((Point){p[mid].x, p[i].y});
  }
  dfs(l, mid - 1);
  dfs(mid + 1, r);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d%d", &p[i].x, &p[i].y);
    out.insert(p[i]);
  }
  sort(p + 1, p + n + 1);
  dfs(1, n);
  printf("%d\n", out.size());
  for (int i = 1; i <= n; ++i) {
    printf("%d %d\n", p[i].x, p[i].y);
    out.erase(p[i]);
  }
  set<Point>::iterator pos;
  for (pos = out.begin(); pos != out.end(); ++pos) {
    printf("%d %d\n", (*pos).x, (*pos).y);
  }
  return 0;
}
