n = int(input()) ls = [list(map(int, input().split())) + [i] for i in range(n)] ls.sort() print(n//2) for i in range(n//2): print(ls[i*2][2]+1, ls[i*2+1][2] + 1)