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