#include <bits/stdc++.h>
using namespace std;
struct point:pair<int,int>
{
point(int x = 0, int y = 0)
{
first = x, second = y;
}
int Manhattan_dist(const point& p) const
{
return abs(first-p.first)+abs(second-p.second);
}
friend istream& operator >> (istream& in, point& p)
{
return in >> p.first >> p.second;
}
friend ostream& operator << (ostream& out, const point& p)
{
return out << p.first << ' ' << p.second;
}
};
struct points:set<point>
{
void connect(const point& s, const point& t)
{
int x = s.first, y = s.second,
u = t.first, v = t.second;
for(int z = x+1; z <= u; x = z++) // move right
emplace(z,y);
for(int z = y+1; z < v; y = z++) // move up
emplace(x,z);
for(int z = y-1; z > v; y = z--) // move down
emplace(x,z);
insert(t);
}
points(int n)
{
vector<point> p(n);
for(auto&q:p)
cin >> q;
sort(p.begin(),p.end()), insert(p[0]), connect(p[0],p[1]);
for(int i = 2; i < n; i++)
{
point src; int d_min = INT_MAX; bool connected = false;
for(auto q:*this)
if (q == p[i])
{
connected = true; break;
}
else
{
int d = q.Manhattan_dist(p[i]);
if(d < d_min)
src = q, d_min = d;
}
if (not connected)
connect(src,p[i]);
}
}
friend ostream& operator << (ostream& out, const points& s)
{
out << s.size();
for(auto p:s)
out << '\n' << p;
return out;
}
};
int main()
{
ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
int n; cin >> n; cout << points(n);
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKc3RydWN0IHBvaW50OnBhaXI8aW50LGludD4KewogICAgcG9pbnQoaW50IHggPSAwLCBpbnQgeSA9IDApCiAgICB7CiAgICAgICAgZmlyc3QgPSB4LCBzZWNvbmQgPSB5OwogICAgfQoKICAgIGludCBNYW5oYXR0YW5fZGlzdChjb25zdCBwb2ludCYgcCkgY29uc3QKICAgIHsKICAgICAgICByZXR1cm4gYWJzKGZpcnN0LXAuZmlyc3QpK2FicyhzZWNvbmQtcC5zZWNvbmQpOwogICAgfQoKICAgIGZyaWVuZCBpc3RyZWFtJiBvcGVyYXRvciA+PiAoaXN0cmVhbSYgaW4sIHBvaW50JiBwKQogICAgewogICAgICAgIHJldHVybiBpbiA+PiBwLmZpcnN0ID4+IHAuc2Vjb25kOwogICAgfQoKICAgIGZyaWVuZCBvc3RyZWFtJiBvcGVyYXRvciA8PCAob3N0cmVhbSYgb3V0LCBjb25zdCBwb2ludCYgcCkKICAgIHsKICAgICAgICByZXR1cm4gb3V0IDw8IHAuZmlyc3QgPDwgJyAnIDw8IHAuc2Vjb25kOwogICAgfQp9OwoKc3RydWN0IHBvaW50czpzZXQ8cG9pbnQ+CnsKICAgIHZvaWQgY29ubmVjdChjb25zdCBwb2ludCYgcywgY29uc3QgcG9pbnQmIHQpCiAgICB7CiAgICAgICAgaW50IHggPSBzLmZpcnN0LCB5ID0gcy5zZWNvbmQsIAogICAgICAgIAl1ID0gdC5maXJzdCwgdiA9IHQuc2Vjb25kOwoKICAgICAgICBmb3IoaW50IHogPSB4KzE7IHogPD0gdTsgeCA9IHorKykgLy8gbW92ZSByaWdodAogICAgICAgICAgICBlbXBsYWNlKHoseSk7CgogICAgICAgIGZvcihpbnQgeiA9IHkrMTsgeiA8IHY7IHkgPSB6KyspIC8vIG1vdmUgdXAgCiAgICAgICAgICAgIGVtcGxhY2UoeCx6KTsKICAgICAgIAogICAgICAgIGZvcihpbnQgeiA9IHktMTsgeiA+IHY7IHkgPSB6LS0pIC8vIG1vdmUgZG93bgogICAgICAgICAgICBlbXBsYWNlKHgseik7CgogICAgICAgIGluc2VydCh0KTsKICAgIH0KCiAgICBwb2ludHMoaW50IG4pCiAgICB7CiAgICAgICAgdmVjdG9yPHBvaW50PiBwKG4pOwoKICAgICAgICBmb3IoYXV0byZxOnApCiAgICAgICAgICAgIGNpbiA+PiBxOwoKICAgICAgICBzb3J0KHAuYmVnaW4oKSxwLmVuZCgpKSwgaW5zZXJ0KHBbMF0pLCBjb25uZWN0KHBbMF0scFsxXSk7CgogICAgICAgIGZvcihpbnQgaSA9IDI7IGkgPCBuOyBpKyspCiAgICAgICAgewogICAgICAgICAgICBwb2ludCBzcmM7IGludCBkX21pbiA9IElOVF9NQVg7IGJvb2wgY29ubmVjdGVkID0gZmFsc2U7CgogICAgICAgICAgICBmb3IoYXV0byBxOip0aGlzKQogICAgICAgICAgICAgICAgaWYgKHEgPT0gcFtpXSkKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgICAgICBjb25uZWN0ZWQgPSB0cnVlOyBicmVhazsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgICAgIGVsc2UKICAgICAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIAlpbnQgZCA9IHEuTWFuaGF0dGFuX2Rpc3QocFtpXSk7CiAgICAgICAgICAgICAgICAJCiAgICAgICAgICAgICAgICAJaWYoZCA8IGRfbWluKQogICAgICAgICAgICAgICAgICAgICAgICBzcmMgPSBxLCBkX21pbiA9IGQ7CiAgICAgICAgICAgIAl9CgogICAgICAgICAgICBpZiAobm90IGNvbm5lY3RlZCkKICAgICAgICAgICAgICAgIGNvbm5lY3Qoc3JjLHBbaV0pOwogICAgICAgIH0KICAgIH0KCiAgICBmcmllbmQgb3N0cmVhbSYgb3BlcmF0b3IgPDwgKG9zdHJlYW0mIG91dCwgY29uc3QgcG9pbnRzJiBzKQogICAgewogICAgICAgIG91dCA8PCBzLnNpemUoKTsKCiAgICAgICAgZm9yKGF1dG8gcDpzKQogICAgICAgICAgICBvdXQgPDwgJ1xuJyA8PCBwOwoKICAgICAgICByZXR1cm4gb3V0OwogICAgfQp9OwoKaW50IG1haW4oKQp7CiAgICBpb3NfYmFzZTo6c3luY193aXRoX3N0ZGlvKGZhbHNlKSwgY2luLnRpZShudWxscHRyKSwgY291dC50aWUobnVsbHB0cik7CgoJaW50IG47IGNpbiA+PiBuOyBjb3V0IDw8IHBvaW50cyhuKTsKfQ==