from collections import deque n,m=map(int,input().split()) v=[[] for i in range(n)] for i in range(m): a,b=map(int,input().split());a-=1;b-=1 v[a].append(b);v[b].append(a) for i in range(int(input())): a=int(input())-1 b=[-1]*n;b[a]=1 f=deque() for j in v[a]: f.append(j);b[j]=1 ans=0;c=0 while f: q=f.popleft();c+=1 ans=max(ans,b[q]) for j in v[q]: if b[j]==-1: b[j]=b[q]+1 f.append(j) d=0;f=1 while ans>f: d+=1;f<<=1 ans=d print(c,ans)