from time import time start = time() import sys from random import randint,sample from itertools import combinations from collections import defaultdict 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) B.append(b) NUM = [i for i in range(2,N)] STAND = 5*pow(10,17) def create_abs(A,B,V1,V2,PREV): ABS = list() for v in range(1,N): na,nb = (A[0]+A[v])//2,(B[0]+B[v])//2 if A[0]==A[v] and B[0]==B[v]: continue if PREV[(0,v)]==(na,nb): continue 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(A,B,PREV): # STANDにできるだけ近いやつを作る CAND = list() for (u,v) in combinations(NUM,2): if A[u]==A[v] and B[u]==B[v]: continue na,nb = (A[u]+A[v])//2,(B[u]+B[v])//2 if PREV[(u,v)]==(na,nb): continue n1,n2 = abs(na-STAND),abs(nb-STAND) CAND.append((max(n1,n2),u,v)) CAND.sort() ind = randint(0,5) u,v = CAND[ind][1],CAND[ind][2] return u,v def play(A,B): global MAXV,BEST_ANS TURN = 0 ANS = list() V1,V2 = abs(A[0]-STAND),abs(B[0]-STAND) flag = False PREV = defaultdict(tuple) while TURN<50: if time()-start>0.9: return if flag: u,v = sample(NUM,2) flag = False else: ABS = create_abs(A,B,V1,V2,PREV) if ABS[0][0]==0: # 頭打ちになったら1以外とマージする u,v = sample(NUM,2) elif A[0]==A[ABS[0][1]] and B[0]==B[ABS[0][1]]: u,v = sample(NUM,2) elif ABS[0][0]<0: u,v = sample(NUM,2) else: u,v = 0,ABS[0][1] flag = True ANS.append((u+1,v+1)) na,nb = (A[u]+A[v])//2,(B[u]+B[v])//2 if PREV[(u,v)]==(na,nb): while PREV[(u,v)]==(na,nb): u,v = sample(NUM,2) na,nb = (A[u]+A[v])//2,(B[u]+B[v])//2 if u==0: n1,n2 = abs(na-STAND),abs(nb-STAND) V1,V2 = n1,n2 A[u],A[v],B[u],B[v] = na,na,nb,nb PREV[(u,v)] = (na,nb) PREV[(v,u)] = (na,nb) TURN += 1 if MAXV>max(V1,V2): MAXV = max(V1,V2) BEST_ANS = [a[:] for a in ANS] return BEST_ANS = list() MAXV = pow(10,18) while time()-start<0.9: AA = A[:] BB = B[:] play(AA,BB) print(len(BEST_ANS)) for u,v in BEST_ANS: print(u,v)