import sys import math import bisect from heapq import heapify, heappop, heappush from collections import deque, defaultdict, Counter from functools import lru_cache from itertools import accumulate, combinations, permutations, product sys.setrecursionlimit(1000000) MOD = 10 ** 9 + 7 MOD99 = 998244353 input = lambda: sys.stdin.readline().strip() NI = lambda: int(input()) NMI = lambda: map(int, input().split()) NLI = lambda: list(NMI()) SI = lambda: input() SMI = lambda: input().split() SLI = lambda: list(SMI()) EI = lambda m: [NLI() for _ in range(m)] def score(a, b, x): v1 = abs(5 * 10**17 - a) v2 = abs(5 * 10**17 - b) if max(v1, v2) > 0: return int(2000000 - 100000 * math.log10(max(v1, v2)+1)) else: return 2000050 - x def answer(ans): print(len(ans)) for i, j in ans: print(i+1, j+1) def main(): N = NI() AB = EI(N) ans = [] # 0と何かだけで貪欲 for qi in range(50): a0, b0 = AB[0] s = score(a0, b0, qi) best_s = s best_v = 1 for v in range(1, N): av, bv = AB[v] na, nb = (a0+av) // 2, (b0+bv) // 2 ns = score(na, nb, qi+1) if ns > best_s: best_s = ns best_v = v if best_s > s: av, bv = AB[best_v] na, nb = (a0 + av) // 2, (b0 + bv) // 2 AB[0] = [na, nb] AB[best_v] = [na, nb] ans.append([0, best_v]) else: break answer(ans) if __name__ == "__main__": main()