#include <bits/stdc++.h>
using namespace std;
template <class T, class T2>
inline int chkmax(T &x, const T2 &y) {
  return x < y ? x = y, 1 : 0;
}
template <class T, class T2>
inline int chkmin(T &x, const T2 &y) {
  return x > y ? x = y, 1 : 0;
}
const int MAXN = (1 << 20);
int n;
pair<int, int> a[MAXN];
void read() {
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second;
}
vector<pair<int, int> > answer;
void rec(int l, int r) {
  if (l == r) return;
  int mid = (l + r) >> 1;
  for (int i = l; i <= r; i++) answer.push_back({a[mid].first, a[i].second});
  rec(l, mid);
  rec(mid + 1, r);
}
void solve() {
  sort(a + 1, a + n + 1);
  rec(1, n);
  for (int i = 1; i <= n; i++) answer.push_back(a[i]);
  sort(answer.begin(), answer.end());
  answer.erase(unique(answer.begin(), answer.end()), answer.end());
  cout << answer.size() << '\n';
  for (auto it : answer) cout << it.first << " " << it.second << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  read();
  solve();
  return 0;
}
