#!/usr/bin/pypy3 from collections import deque N = 199993 L = 39999 G = [[] for i in range(N + 1)] p = 6000 for i in range(1, L): G[i].append(i + 1) G[i + 1].append(i) id = L + 1 for u in range(1, L + 1): now = u if u == p: # 縦に 3 つ G[now].append(id) G[id].append(now) id += 1 G[now].append(id) G[id].append(now) id += 1 else: # 縦に 5 つ G[now].append(id) G[id].append(now) now = id id += 1 G[now].append(id) G[id].append(now) id += 1 now = u G[now].append(id) G[id].append(now) now = id id += 1 G[now].append(id) G[id].append(now) id += 1 S = deque() S.append(1) visited = [False] * (N + 1) print(N) while len(S) > 0: now = S.pop() visited[now] = True for nx in G[now]: if visited[nx]: continue print(min(now, nx), max(now, nx)) S.append(nx)