from time import time start = time() import sys,math if len(sys.argv) == 2: sys.stdin = open(sys.argv[1]) from random import randint,randrange,sample,shuffle,choice from collections import defaultdict,deque from itertools import combinations,permutations,accumulate,product from bisect import bisect,bisect_left,bisect_right from heapq import heappop,heappush,heapify from copy import deepcopy def input(): return sys.stdin.readline().rstrip() def ii(): return int(input()) def ms(): return map(int, input().split()) def li(): return list(map(int,input().split())) # //////////////////////////////// N = ii() A = list() B = list() for i in range(N): a,b = ms() A.append([a,i]) B.append([b,i]) NUM = [i for i in range(2,N)] STAND = 5*pow(10,17) TURN = 0 V1,V2 = abs(A[0][0]-STAND),abs(B[0][0]-STAND) def create_abs(): ABS = list() for v in range(1,N): na,nb = (A[0][0]+A[v][0])//2,(B[0][0]+B[v][0])//2 n1,n2 = abs(na-STAND),abs(nb-STAND) tmp = max(V1,V2)-max(n1,n2) ABS.append((tmp,v)) ABS.sort(reverse=True) return ABS def other_merge(): # STANDにできるだけ近いやつを作る CAND = list() for (u,v) in combinations(NUM,2): na,nb = (A[u][0]+A[v][0])//2,(B[u][0]+B[v][0])//2 n1,n2 = abs(na-STAND),abs(nb-STAND) CAND.append((max(n1,n2),u,v)) CAND.sort() u,v = CAND[0][1],CAND[0][2] return u,v ANS = list() while TURN<50: if time()-start>2.85: break ABS = create_abs() if ABS[0][0]==0: # 頭打ちになったら1以外とマージする u,v = other_merge() else: u,v = 0,ABS[0][1] ANS.append((u+1,v+1)) na,nb = (A[u][0]+A[v][0])//2,(B[u][0]+B[v][0])//2 if u==0: n1,n2 = abs(na-STAND),abs(nb-STAND) V1,V2 = n1,n2 A[u][0],A[v][0],B[u][0],B[v][0] = na,na,nb,nb TURN += 1 print(len(ANS)) for u,v in ANS: print(u,v)