from collections import deque N = int(input()) def bfs(): visited = [0]*(N+1) visited[1] = 1 d = deque() d.append(1) def f(v,x): if 0