#include <bits/stdc++.h>
using namespace std;
struct Point {
  int x, y;
  Point() {}
  Point(int _x, int _y) : x(_x), y(_y) {}
};
inline bool operator<(const Point& p, const Point& q) {
  return p.x < q.x || (p.x == q.x && p.y < q.y);
}
inline bool operator==(const Point& p, const Point& q) {
  return p.x == q.x && p.y == q.y;
}
vector<Point> res;
void solve(vector<Point>::iterator b, vector<Point>::iterator e) {
  if (b == e) return;
  int n = e - b;
  vector<Point>::iterator i = b, j = b;
  while (true) {
    while (j != e && i->x == j->x) ++j;
    if (j - b > n / 2) break;
    i = j;
  }
  for (vector<Point>::iterator p = i; p != j; ++p) res.push_back(*p);
  for (vector<Point>::iterator p = b; p != i; ++p)
    res.push_back(Point(i->x, p->y));
  for (vector<Point>::iterator p = j; p != e; ++p)
    res.push_back(Point(i->x, p->y));
  solve(b, i);
  solve(j, e);
}
int main() {
  int n;
  scanf("%d", &n);
  vector<Point> p;
  p.reserve(n);
  for (int i = 0; i < n; ++i) {
    int x, y;
    scanf("%d%d", &x, &y);
    p.push_back(Point(x, y));
  }
  sort(p.begin(), p.end());
  solve(p.begin(), p.end());
  sort(res.begin(), res.end());
  res.resize(unique(res.begin(), res.end()) - res.begin());
  printf("%d\n", (int)res.size());
  for (int i = 0; i < (int)res.size(); ++i)
    printf("%d %d\n", res[i].x, res[i].y);
  return 0;
}
