# 問題読み間違えていた、頂点1とNを連結したい # それならダイクストラだろう N, M = map(int, input().split()) edges = [[] for i in range(N+1)] for i in range(M): a, b = map(int, input().split()) edges[a].append((b, 1)) edges[b].append((a, 1)) from heapq import heappush, heappop INF = 10 ** 18 def dijkstra(s, n, connect): #(始点, ノード数) distance = [INF] * n que = [(0, s)] #(distance, node) distance[s] = 0 confirmed = [False] * n # ノードが確定済みかどうか while que: w,v = heappop(que) if distance[v]