from collections import Counter def find(A,x): p = A[x] if p == x: return x a = find(A,p) A[x] = a return a def union(A, x, y): # bx, by = sorted([find(A,x), find(A,y)]) # bx, by = find(A,x), find(A,y)だと無限ループ。 if find(A,x) > find(A,y): bx, by = find(A,y), find(A,x) else: bx, by = find(A,x), find(A,y) A[y] = bx A[by] = bx N, M = map( int, input().split()) E = [ [] for _ in range(N)] V = [ i for i in range(N)] for _ in range(M): p, q = map( int, input().split()) p, q = p-1, q-1 union(V, p ,q) E[p].append(q) E[q].append(p) for i in range(N): _ = find(V,i) CV = Counter(V) Q = int( input()) A = [ int( input()) for _ in range(Q)] A = list( map( lambda x:x-1, A)) for i in range(Q): # print( CV[find(V,A[i])], len(E[A[i]]), A[i]) print( CV[find(V,A[i])]-1, CV[find(V,A[i])] -1 - len(E[A[i]]))