#include #define rep(i,n) for(int i=0;i ; const ll INF = 1e14; const int MOD = 1000000007; int main(){ int n,m; cin >> n >> m; vector> graph(n,vector()); rep(i,m){ int a,b; cin >> a >> b; --a;--b; graph[a].push_back(b); graph[b].push_back(a); } int q; cin >> q; rep(_,q){ int a; cin >> a; --a; int cnt = 0; int d = 0; vector day(n,-1); queue q; q.push(a); day[a] = 0; while(!q.empty()){ int now = q.front(); if(now != a) cnt ++; q.pop(); for(int next:graph[now]){ if(day[next] >= 0 ) continue; day[next] = day[now] + 1; d = max(d,day[next]); q.push(next); } } int ans = 0; int res = 1; while(res < d) res *= 2,ans++; cout << cnt << " " << ans << endl; } }