import heapq def dijkstra(s): inf = 10**9 d = [inf]*N used = [0]*N h = [s] while h: temp = heapq.heappop(h) dist = temp//N u = temp%N if used[u] == 1: continue used[u] = 1 d[u] = dist for v in E[u]: if used[v] == 1: continue heapq.heappush(h, (dist+1)*N+v) return d N,M = map(int, input().split()) E = [[] for _ in range(N+1)] for _ in range(M): p,q = map(int, input().split()) E[p-1].append(q-1) E[q-1].append(p-1) Q = int(input()) for _ in range(Q): a = int(input()) d = dijkstra(a-1) num = -1 dist = 0 for i in range(N): if d[i] == 10**9: continue dist = max(dist, d[i]-1) num += 1 cnt = 0 for i in range(dist+1): if cnt >= dist: day = i break cnt += 1<