from dataclasses import dataclass, field # from sortedcontainers import SortedList, SortedDict, SortedSet from random import random, seed, randrange, choice, sample # from itertools import permutations, combinations, product from collections import deque, defaultdict, Counter # from heapq import heapify, heappush, heappop # from bisect import bisect_right, bisect_left from time import time import sys sys.setrecursionlimit(1000000) seed(0) def input(): return sys.stdin.buffer.readline().rstrip().decode(encoding='utf-8') try: isLocal except: isLocal = False if isLocal: input = line def randrange_s(stop:int)->int: return int(random()*stop) def randrange_ss(start:int, stop:int)->int: return int(random()*(stop-start)+start) class AHC(): def __init__(self): self.sTime = time() self.get_input() self.preprocessing() def get_input(self): self.N = int(input()) AB = [list(map(int, input().split())) for _ in range(self.N)] self.A, self.B = [], [] for a, b in AB: self.A.append(float(a)) self.B.append(float(b)) return def preprocessing(self): self.target = float(5*10**17) return def get_score(self): return max(abs(self.target-self.A[0]), abs(self.target-self.B[0])) def get_score2(self, a, b): return max(abs(self.target-a), abs(self.target-b)) def greedy(self): self.ans = [] self.hist = set() self.cur = self.get_score() self.cnt = 0 self.eTime = self.sTime+0.9 while self.cnt<50 and time()=self.cur: break self.hist = set() self.cnt += 1 self.cur = nxt self.ans.append(f"1 {v+1}") mean = (self.A[0]+self.A[v])/2 self.A[0] = mean self.A[v] = mean mean = (self.B[0]+self.B[v])/2 self.B[0] = mean self.B[v] = mean # カード1を理想の状態にするためのカード作り target_A = self.target-self.A[0]+self.target target_B = self.target-self.B[0]+self.target evaList = [] for u in range(1, self.N-1): for v in range(u+1, self.N): if (u, v) in self.hist: continue a = (self.A[u]+self.A[v])/2 b = (self.B[u]+self.B[v])/2 evaList.append([(target_A-a)**2+(target_B-b)**2, u, v]) if len(evaList)==0: break _, u, v = min(evaList) self.cnt += 1 self.ans.append(f"{u+1} {v+1}") self.hist.add((u, v)) mean = (self.A[u]+self.A[v])/2 self.A[u] = mean self.A[v] = mean mean = (self.B[u]+self.B[v])/2 self.B[u] = mean self.B[v] = mean return def output(self): print(len(self.ans)) if len(self.ans)>0: print("\n".join(self.ans)) ahc = AHC() ahc.greedy() ahc.output()