#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) #define srep(i,s,t) for (int i = s; i < t; ++i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("Yes");}else{puts("No");} struct edge{ int to, cost, id; }; const int INF = 1001001001; const int MAX_N = 200005; vector G[MAX_N]; int main() { int n, m; cin >> n >> m; rep(i,m){ int from = 0, to = 0, cost = 1, id = i;; cin >> from >> to; from--; to--; edge e1, e2; e1.to = to; e1.cost = cost; e1.cost = cost; e1.id = id; e2.to = from; e2.cost = cost; e2.cost = cost; e2.id = id; G[from].push_back(e1); G[to].push_back(e2); } int Q; cin >> Q; rep(_,Q){ int a; cin >> a; a--; queue que; que.push(a); int d[n] = {}; int f[n] = {}; f[a] = 1; while(que.size()>0){ int x = que.front(); que.pop(); rep(i,G[x].size()){ int y = G[x][i].to; if(f[y]) continue; d[y] = d[x]+1; f[y] = 1; que.push(y); } } int ans = -1; int ma = 0; rep(i,n){ if(f[i]){ ans++; ma = max(ma,d[i]); } } ma--; if(ma<0)ma++; cout << ans << ' ' << ma << endl; } return 0; }