from math import log10, floor from random import randint from time import time time_start = time() N = int(input()) init_A, init_B = [list(i) for i in zip(*[list(map(int, input().split())) for _ in range(N)])] def calc_socre(op): A, B = exec_op(op) X = len(op) V1, V2 = abs(5*10**17-A[0]), abs(5*10**17-B[0]) V = max(V1, V2) if V == 0: return 2000050 - X else: return floor(2000000.0 - 100000.0 * log10(V+1)) def exec_op(op): A, B = init_A[:], init_B[:] for u, v in op: a, b = A[u-1], A[v-1] A[u-1], A[v-1] = (a+b)//2, (a+b)//2 c, d = B[u-1], B[v-1] B[u-1], B[v-1] = (c+d)//2, (c+d)//2 return A, B X = 50 op = [] for _ in range(X): u = randint(1, N-1) v = randint(u+1, N) op.append((u, v)) # 山登り法 score = calc_socre(op) while time() - time_start < 0.90: # 確率0.5で一点変異 if randint(0, 1): u = randint(1, N-1) v = randint(u+1, N) op[randint(0, X-1)] = (u, v) else: u, v = randint(0, X-1), randint(0, X-1) op[u], op[v] = op[v], op[u] new_score = calc_socre(op) if new_score > score: score = new_score else: op[u], op[v] = op[v], op[u] print(X) for u, v in op: print(u, v)