#include <bits/stdc++.h>
using namespace std;
pair<int, int> A[200010];
int ans;
void cdq(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  cdq(l, mid);
  cdq(mid + 1, r);
  for (int i = l; i <= r; i++) {
    A[++ans].first = A[mid].first;
    A[ans].second = A[i].second;
  }
}
void solve() {
  int n;
  scanf("%d", &n);
  ans = n;
  for (int i = 1; i <= n; i++) scanf("%d%d", &A[i].first, &A[i].second);
  sort(A + 1, A + n + 1);
  cdq(1, n);
  sort(A + 1, A + ans + 1);
  ans = unique(A + 1, A + ans + 1) - A - 1;
  cout << ans << endl;
  for (int i = 1; i <= ans; i++)
    cout << A[i].first << " " << A[i].second << endl;
}
int main() {
  solve();
  return 0;
}
