N = int(input()) dogs = [tuple(list(map(int, input().split())) + [i + 1]) for i in range(N)] dogs = sorted(dogs) print(N // 2) for i in range(0, N - 1, 2): print(dogs[i][2], dogs[i + 1][2])