#include<stdio.h>
#include<deque>
#include<algorithm>
using namespace std;
class node{
public:
int x,y,num;
}dum;
bool func(node i,node j)
{
if(i.y > j.y)
return true;
return false;
}
int main()
{
deque<node> city;
int n; scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d %d",&dum.x,&dum.y);
dum.num = (i+1);
city.push_back(dum);
}
if(n == 0)
{printf("0");return 0;}
sort(city.begin(),city.end(),func);
for(int i=0;i<n;i+=2)
{
printf("%d %d\n",city[i].num,city[i+1].num);
}
}
I2luY2x1ZGU8c3RkaW8uaD4KI2luY2x1ZGU8ZGVxdWU+CiNpbmNsdWRlPGFsZ29yaXRobT4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKY2xhc3Mgbm9kZXsKICAgIHB1YmxpYzoKICAgIGludCB4LHksbnVtOwp9ZHVtOwpib29sIGZ1bmMobm9kZSBpLG5vZGUgaikKewogICAgaWYoaS55ID4gai55KQogICAgcmV0dXJuIHRydWU7CiAgICByZXR1cm4gZmFsc2U7Cn0KaW50IG1haW4oKQp7CiAgICBkZXF1ZTxub2RlPiBjaXR5OwogICAgaW50IG47ICAgIHNjYW5mKCIlZCIsJm4pOwogICAgZm9yKGludCBpPTA7aTxuO2krKykKICAgIHsKICAgICAgICBzY2FuZigiJWQgJWQiLCZkdW0ueCwmZHVtLnkpOwogICAgICAgIGR1bS5udW0gPSAoaSsxKTsKICAgICAgICBjaXR5LnB1c2hfYmFjayhkdW0pOwogICAgfQogICAgaWYobiA9PSAwKQogICAge3ByaW50ZigiMCIpO3JldHVybiAwO30KICAgIHNvcnQoY2l0eS5iZWdpbigpLGNpdHkuZW5kKCksZnVuYyk7CiAgICBmb3IoaW50IGk9MDtpPG47aSs9MikKICAgIHsKICAgICAgICBwcmludGYoIiVkICVkXG4iLGNpdHlbaV0ubnVtLGNpdHlbaSsxXS5udW0pOwogICAgfQp9