from collections import deque N,M = map(int,input().split()) l = [[]for _ in range(N+1)] ans = [[0,0] for _ in range(N+1)] print(ans) for _ in range(M): p,q = map(int,input().split()) l[p].append(q) l[q].append(p) Q = int(input()) for _ in range(Q): i = int(input()) que = deque([i]) check = [0]*(N+1) check[i] = 1 friends,days = 0,-1 while que: num = que.pop() for j in l[num]: if check[j] == 0: que.append(j) check[j] = 1 friends += 1 days += 1 print(friends,days)