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