n=int(input()) p=[tuple(map(int,input().split())) for i in range(n)] L=8000 q=[[] for i in range(L+1)] for i in range(n): x,y=p[i] q[y]+=[(x,i)] a=[] for i in range(L+1): q[i].sort() for _,j in q[i]: a+=[j+1] print(n//2) for i in range(n//2): print(a[i*2],a[i*2+1])