#int(input()) #map(int, input().split()) #list(map(int, input().split())) import time import random from math import floor, log10 N = int(input()) u = [0] * (2 * N) for i in range(N): a, b = map(int, input().split()) u[i] = a u[i+N] = b ut = time.time() def get_score(u): c = 5 * 10 ** 17 v1 = abs(u[0] - c) v2 = abs(u[N] - c) s = floor(2 * 10 ** 6 - 10 ** 5 * log10(max(v1, v2) + 1)) return s M = 50 ans = [0] * (2 * M) for i in range(2*M): ans[i] = random.randint(0, N-1) # for i in range(10): # ans[i] = 0 def f(a): nu = list(u) for i in range(M): if a[i] == a[i+M]: continue x = a[i] y = a[i+M] nu[x] = floor((nu[x]+nu[y]) / 2) nu[y] = nu[x] nu[x+N] = floor((nu[x+N]+nu[y+N]) / 2) nu[y+N] = nu[y+N] return nu nows = get_score(f(ans)) count = 0 while time.time() - ut < 0.9: nans = list(ans) t = random.randint(0, 2*M-1) n = random.randint(0, N-1) nans[t] = n s = get_score(f(nans)) if s > nows: ans = list(nans) # print(s, nows) nows = s count += 1 fa = f(ans) # print(count) # print(fa[:3], fa[N:N+3]) def stdout(ans): l = [] for i in range(M): if ans[i] == ans[i+M]: continue l.append([ans[i], ans[i+M]]) print(len(l)) for x in l: print(*x) stdout(ans)