N = int(input()) inu = [] for i in range(N): x,y = map(int,input().split()) inu.append((x,y,i + 1)) inu.sort() print(N // 2) for _ in range(N // 2): x,y,i = inu.pop() xx,yy,ii = inu.pop() print(i,ii)