#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
int n;
vector<pair<int, int> > coords;
vector<vector<int> > g;
vector<bool> A;
vector<bool> B;
vector<bool> vis;
vector<int> pr;
vector<bool> win;
void get_parties(int cur, bool which) {
if(which) {
A[cur] = true;
} else {
B[cur] = true;
}
vis[cur] = true;
for(int nei : g[cur]) {
if(!vis[nei]) {
get_parties(nei, !which);
}
}
}
bool dfs(int a) {
if(vis[a]) {
return false;
}
vis[a] = true;
for(int b : g[a]) {
if(pr[b] == -1 || dfs(pr[b])) {
pr[b] = a;
pr[a] = b;
return true;
}
}
return false;
}
void win_a(int cur) {
if(vis[cur]) {
return;
}
vis[cur] = true;
if(A[cur]) {
win[cur] = true;
}
for(int nei : g[cur]) {
if((A[cur] && pr[cur] != nei) || (B[cur] && pr[cur] == nei)) {
win_a(nei);
}
}
}
void win_b(int cur) {
if(vis[cur]) {
return;
}
vis[cur] = true;
if(B[cur]) {
win[cur] = true;
}
for(int nei : g[cur]) {
if((B[cur] && pr[cur] != nei) || (A[cur] && pr[cur] == nei)) {
win_b(nei);
}
}
}
void solve() {
cin >> n;
coords.assign(1 + n, mp(0, 0));
for(int i = 1; i <= n; i++) {
cin >> coords[i].fi >> coords[i].se;
}
g.resize(1 + n);
for(int i = 1; i <= n; i++) {
for(int j = i + 1; j <= n; j++) {
if(abs(coords[i].fi - coords[j].fi) + abs(coords[i].se - coords[j].se) == 1) {
g[i].pb(j);
g[j].pb(i);
}
}
}
A.assign(1 + n, false);
B.assign(1 + n, false);
vis.assign(1 + n, false);
for(int i = 1; i <= n; i++) {
if(!vis[i]) {
get_parties(i, 0);
}
}
pr.assign(1 + n, -1);
for(int i = 1; i <= n; i++) {
if(A[i]) {
vis.assign(1 + n, false);
dfs(i);
}
}
win.assign(1 + n, false);
vis.assign(1 + n, false);
for(int i = 1; i <= n; i++) {
if(A[i] && pr[i] == -1) {
win_a(i);
}
}
vis.assign(1 + n, false);
for(int i = 1; i <= n; i++) {
if(B[i] && pr[i] == -1) {
win_b(i);
}
}
vector<int> ans;
for(int i = 1; i <= n; i++) {
if(win[i]) {
ans.pb(i);
}
}
cout << (int) ans.size() << "\n";
for(int cur : ans) {
cout << coords[cur].fi << " " << coords[cur].se << "\n";
}
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
solve();
return 0;
}