I,R,P=input,range,print N=int(I()) x=[list(map(int,I().split()))+[i+1]for i in R(N)] N//=2 P(N) x.sort() for i in R(N):P(x[i*2][2],x[i*2+1][2])