from collections import deque n,m = map(int,input().split()) G = [[] for _ in range(n)] for _ in range(m): a,b = map(int,input().split()) a -= 1 b -= 1 G[a].append(b) G[b].append(a) q = int(input()) for _ in range(q): s = int(input()) s -= 1 dist = [-1] * n dist[s] = 0 q = deque([s]) ret = 0 while q: p = q.popleft() for v in G[p]: if dist[v] >= 0: continue ret += 1 dist[v] = dist[p] + 1 q.append(v) D = max(dist) day = 0 d = 1 while d < D: d *= 2 day += 1 print(ret,day)