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