#include using namespace std; #define int long long vector graph[100010]; signed main(){ int n, m; cin >> n >> m; int a, b; for(int i = 0;i < m;i++){ cin >> a >> b; a--, b--; graph[a].push_back(b); graph[b].push_back(a); } int q; cin >> q; for(int p = 0;p < q;p++){ int dist[100010]; memset(dist, -1, sizeof(dist)); int fi; cin >> fi; queue> que; fi--; que.push(make_pair(fi, 0)); int cnt = 0; while(!que.empty()){ int idx = que.front().first; int cost = que.front().second; que.pop(); if(cost != 0) cnt++; if(dist[idx] != -1) continue; dist[idx] = cost; for(int i = 0;i < graph[idx].size();i++){ if(dist[graph[idx][i]] == -1){ que.push(make_pair(graph[idx][i], cost+1)); } } } int ma = -2; for(int i = 0;i < n;i++){ ma = max(ma, dist[i]); } int ans; int i; for(i = 0,ans=1;ans < ma;i++,ans*=2); cout << cnt << " " << i << endl; } return 0; }