N,M = map(int,input().split()) G = [[] for _ in range(N)] for _ in range(M): p,q = map(int,input().split()) p -= 1 q -= 1 G[p].append(q) G[q].append(p) Q = int(input()) from collections import deque for _ in range(Q): A = int(input()) A -= 1 q = deque([A]) dist = [-2] * N dist[A] = -1 count = 0 ans = 0 while q: now = q.popleft() for v in G[now]: if dist[v] == -2: dist[v] = dist[now] + 1 if dist[v] > ans: ans = dist[v] count += 1 q.append(v) print(count,(ans + 1) // 2)