N = int(input()) XY = [] for i in range(N): x,y = map(int,input().split()) XY.append((x,y,i+1)) XY.sort() print(N//2) for i in range(N//2): print(XY[2 * i][2],XY[2 * i + 1][2])