import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict from collections import deque con = 10 ** 9 + 7; INF = float("inf") def getlist(): return list(map(int, input().split())) class Graph(object): def __init__(self): self.graph = defaultdict(list) def __len__(self): return len(self.graph) def add_edge(self, a, b): self.graph[a].append(b) class BFS(object): def __init__(self, graph, s, N): self.g = graph.graph self.Q = deque(); self.Q.append(s) self.dist = [INF] * N; self.dist[s] = 0 while self.Q: v = self.Q.popleft() for i in self.g[v]: if self.dist[i] == INF: self.dist[i] = self.dist[v] + 1 self.Q.append(i) #処理内容 def main(): N, M = getlist() G = Graph() for i in range(M): a, b = getlist() a -= 1; b -= 1 G.add_edge(a, b) G.add_edge(b, a) Q = int(input()) for _ in range(Q): A = int(input()) A -= 1 BF = BFS(G, A, N) cnt = 0 MAX = 0 for i in range(N): d = BF.dist[i] if d != INF: cnt += 1 MAX = max(MAX, d) cnt -= 1 if MAX == 0: day = 0 else: for i in range(1, 50): if 2 ** i >= MAX: day = i break print(cnt, day) if __name__ == '__main__': main()