#include using namespace std; using ll = long long; #define FOR(i,a,b) for(ll i=(a);i<(b);++i) #define ALL(v) (v).begin(), (v).end() #define p(s) cout<<(s)< > G; vector d; pair bfs(ll i){ fill(ALL(d), -1); d[i] = 0; queue que; que.push(i); pair answer; ll friend_num = 0; ll longest_distance = 0; while(!que.empty()){ ll a = que.front(); que.pop(); for(ll to : G[a]){ if(d[to]==-1){ d[to] = d[a]+1; que.push(to); friend_num++; } } } longest_distance = *max_element(ALL(d)); if(friend_num==0){ answer.first = 0; answer.second = 0; } else{ ll days = ceil(log2(longest_distance)); answer.first = friend_num; answer.second = days; } return answer; } int main(){ cin.tie(0); ios::sync_with_stdio(false); // input ll N, M; cin >> N >> M; G.resize(N+1); d.resize(N+1); FOR(i, 0, M){ ll p, q; cin >> p >> q; G[p].push_back(q); G[q].push_back(p); } ll Q; cin >> Q; FOR(i, 0, Q){ ll a; cin >> a; auto p = bfs(a); p2(p.first, p.second); } return 0; }