#include<iostream>
#include<math.h>
#include<iomanip>
#include<string>
#include<algorithm>
#include<map>
#include<stack>
#include<deque>
#include<cstdio>
#include<queue>
#include<fstream>
using namespace std;
int main() {
ifstream cin("hobby.in");
ofstream cout("hobby.out");
int n,i,j,m,z,x;
pair< int,pair<int,int> >a[1005];
cin>>n;
for(i=0;i<n;i++) {
cin>>a[i].first>>a[i].second.first;
a[i].second.second=i+1;
}
sort(a+0,a+n);
cout<<n/2<<endl;
for(i=1;i<n;i+=2) {
cout<<a[i-1].second.second<<" "<<a[i].second.second<<endl;
}
return 0;
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPG1hdGguaD4KI2luY2x1ZGU8aW9tYW5pcD4KI2luY2x1ZGU8c3RyaW5nPgojaW5jbHVkZTxhbGdvcml0aG0+CiNpbmNsdWRlPG1hcD4KI2luY2x1ZGU8c3RhY2s+CiNpbmNsdWRlPGRlcXVlPgojaW5jbHVkZTxjc3RkaW8+CiNpbmNsdWRlPHF1ZXVlPgojaW5jbHVkZTxmc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwppbnQgbWFpbigpIHsKIGlmc3RyZWFtIGNpbigiaG9iYnkuaW4iKTsKIG9mc3RyZWFtIGNvdXQoImhvYmJ5Lm91dCIpOwogaW50IG4saSxqLG0seix4OwogcGFpcjwgaW50LHBhaXI8aW50LGludD4gPmFbMTAwNV07CiBjaW4+Pm47CiBmb3IoaT0wO2k8bjtpKyspIHsKICBjaW4+PmFbaV0uZmlyc3Q+PmFbaV0uc2Vjb25kLmZpcnN0OwogIGFbaV0uc2Vjb25kLnNlY29uZD1pKzE7CiB9CiBzb3J0KGErMCxhK24pOwogY291dDw8bi8yPDxlbmRsOwogZm9yKGk9MTtpPG47aSs9MikgewogIGNvdXQ8PGFbaS0xXS5zZWNvbmQuc2Vjb25kPDwiICI8PGFbaV0uc2Vjb25kLnNlY29uZDw8ZW5kbDsKIH0KIHJldHVybiAwOwp9