N = int(input()) point = [] for pi in range(1, N + 1): x, y = map(int, input().split()) point.append((x, y, pi)) point.sort() print(len(point) // 2) for i in range(0, N, 2): try: print(point[i][2], point[i + 1][2]) except IndexError: exit()