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