#include <bits/stdc++.h>
const int LIM = 1000000000;
using namespace std;
struct Point {
  int x, y;
  Point(int _x, int _y) : x(_x), y(_y) {}
  Point() {}
  bool operator<(const Point &b) const {
    if (x != b.x) return x < b.x;
    return y > b.y;
  }
  bool operator==(const Point &b) const { return x == b.x && y == b.y; }
};
vector<Point> ans, pts;
void split(int l, int r) {
  if (r - l == 1) return;
  int mid = (l + r - 1) >> 1;
  for (int i = l; i <= mid; i++) ans.push_back(Point(pts[mid].x, pts[i].y));
  for (int i = mid + 1; i < r; i++) ans.push_back(Point(pts[mid].x, pts[i].y));
  split(l, mid + 1);
  split(mid + 1, r);
}
bool xcmp(const Point &a, const Point &b) { return a.x < b.x; }
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d %d", &x, &y);
    pts.push_back(Point(x, y));
  }
  for (int i = 0; i < pts.size(); i++) ans.push_back(pts[i]);
  sort(pts.begin(), pts.end(), xcmp);
  split(0, pts.size());
  sort(ans.begin(), ans.end());
  ans.resize(unique(ans.begin(), ans.end()) - ans.begin());
  printf("%d\n", (int)ans.size());
  for (int i = 0; i < ans.size(); i++) printf("%d %d\n", ans[i].x, ans[i].y);
}
