from collections import deque N, M = map(int,input().split()) G = [list() for _ in range(N)] for i in range(M): p, q = map(int, input().split()) p-=1;q-=1 G[p].append(q) G[q].append(p) Q = int(input()) for i in range(Q): A = int(input()) d = deque() dis = [-1]*N dis[A-1] = 0 d.append(A-1) while d: v = d.popleft() for nex in G[v]: if dis[nex]==-1: dis[nex] = dis[v]+1 d.append(nex) m = max(dis) cnt = 0 while m>1: if m%2==0: cnt += 1 m //= 2 else: cnt += 1 m += 1 m //= 2 print(N-dis.count(-1)-1,cnt)