#include using namespace std; using ll = long long; const ll goal = 5e17; int N; ll A[45], B[45], C[45]; int main(void){ ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; for(int i = 0;i < N;i++){ cin >> A[i] >> B[i]; A[i] -= goal, B[i] -= goal; C[i] = (A[i] - B[i]); } vector cid; for(int i = 0;i < N;i++)cid.push_back(i); vector> ans; for(int t = 0;t < 50;t++){ int s, g; if(t < 35){ sort(cid.begin(), cid.end(), [](int x, int y){ return (A[x] - B[x]) < (A[y] - B[y]); }); s = cid.front(); g = cid.back(); if(abs(A[s] - B[s]) < abs(A[g] - B[g]))swap(s, g); ll mn = goal * 2; for(int i : cid){ ll v = (A[s] - B[s]) + (A[i] - B[i]); if(mn > abs(v)){ mn = abs(v); g = i; } } }else if(t < 40){ sort(cid.begin(), cid.end(), [](int x, int y){ return (A[x] - B[x]) < (A[y] - B[y]); }); s = 0; ll mn = goal * 2; for(int i : cid){ ll v = (A[s] - B[s]) + (A[i] - B[i]); if(mn > abs(v)){ mn = abs(v); g = i; } } }else{ sort(cid.begin(), cid.end(), [](auto x, auto y){ return (A[x] + B[x]) / 2 < (A[y] + B[y]) / 2; }); s = 0; ll mn = goal * 2; for(int i : cid){ ll v = (A[0] + A[i]) / 2 + (B[0] + B[i]) / 2; if(mn > abs(v)){ mn = abs(v); g = i; } } } /* for(auto [a, b] : cid){ cerr << a << " "; } cerr << endl; */ if(s == g)continue; A[s] = A[g] = (A[s] + A[g]) / 2; B[s] = B[g] = (B[s] + B[g]) / 2; ans.push_back({s, g}); } cout << ans.size() << endl; for(auto [a, b] : ans){ cout << a + 1 << " " << b + 1 << endl; } return 0; }