import sys input = sys.stdin.readline from collections import deque N,M=map(int,input().split()) table=[[] for i in range(N)] for i in range(M): p,q=map(int,input().split()) p,q=p-1,q-1 table[p].append(q) table[q].append(p) Q=int(input()) A=[int(input())-1 for i in range(Q)] def check(x): #x=A[0] H=deque() H.append(x) visit=[-1]*N visit[x]=0 while H: y=H.popleft() for t in table[y]: if visit[t]==-1: visit[t]=visit[y]+1 H.append(t) day=(max(visit)+1)//2 if max(visit)==1: day=0 num=-1 for i in range(N): if visit[i]!=-1: num+=1 print(max(0,num),max(0,day))#,visit) for a in A: check(a)