#include <bits/stdc++.h>
using namespace std;
const int maxn = 10009;
const int maxm = 100;
const int maxk = 200009;
int n, k;
pair<int, int> pnt[maxn], ans[maxk];
void solve(int l, int r) {
  if (l > r) return;
  if (l == r) {
    ans[k++] = pnt[l];
    return;
  }
  int m = (l + r) / 2;
  for (int i = l; i <= r; i++) {
    ans[k++] = make_pair(pnt[m].first, pnt[i].second);
  }
  solve(l, m);
  solve(m + 1, r);
}
void gen() {
  n = 40;
  printf("%d\n", n);
  for (int i = 0; i < n; i++) {
    int first = abs(rand() * rand()) % 10000000;
    int second = abs(rand() * rand()) % 10000000;
    printf("%d %d\n", first, second);
  }
}
bool check() {
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < i; j++) {
      if (ans[i].first == ans[j].first || ans[i].second == ans[j].second)
        continue;
      bool flag = 0;
      int x1, y1, x2, y2;
      x1 = min(ans[i].first, ans[j].first);
      x2 = max(ans[i].first, ans[j].first);
      y1 = min(ans[i].second, ans[j].second);
      y2 = max(ans[i].second, ans[j].second);
      for (int r = 0; r < k; r++) {
        if (r == i || r == j) continue;
        if (x1 <= ans[r].first && ans[r].first <= x2 && y1 <= ans[r].second &&
            ans[r].second <= y2) {
          flag = 1;
          r = k + 1;
        }
      }
      if (flag == 0) {
        cout << "x1"
             << " : " << x1 << endl;
        cout << "x2"
             << " : " << x2 << endl;
        cout << "y1"
             << " : " << y1 << endl;
        cout << "y2"
             << " : " << y2 << endl;
        cout << "i"
             << " : " << i << endl;
        cout << "j"
             << " : " << j << endl;
        return 0;
      }
    }
  }
  return 1;
}
pair<int, int> ans1[maxk];
int kk;
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d%d", &pnt[i].first, &pnt[i].second);
  sort(pnt, pnt + n);
  solve(0, n - 1);
  sort(ans, ans + k);
  for (int i = 0; i < k; i++) {
    if (i == k - 1 || ans[i] != ans[i + 1]) ans1[kk++] = ans[i];
  }
  printf("%d\n", kk);
  for (int i = 0; i < kk; i++) printf("%d %d\n", ans1[i].first, ans1[i].second);
  return 0;
}
