from collections import defaultdict,deque import sys,heapq,bisect,math,itertools,string,queue,datetime,random sys.setrecursionlimit(10**8) INF = float('inf') mod = 10**9+7 eps = 10**-7 def inpl(): return list(map(int, input().split())) def inpls(): return list(input().split()) N,M = inpl() lines = defaultdict(set) for i in range(M): p,q = inpl() p,q = p-1,q-1 lines[p].add(q) lines[q].add(p) Q = int(input()) for i in range(Q): A = int(input()) A -= 1 q = queue.Queue() q.put([A,0]) link = [0]*N tmp = 0 while not q.empty(): s,depth = q.get() if link[s] == 0: link[s] = 1 for t in lines[s]: q.put([t,depth+1]) tmp = max(tmp,depth) if tmp <= 1: print(sum(link)-1,0) else: print(sum(link)-1,(tmp+1)//2)