#include using namespace std; #ifdef LOCAL_DEBUG #include "LOCAL_DEBUG.hpp" #endif #define int long long const int INF = 1LL << 60; struct edge{ int to,cost; }; vector dikstra(int s,vector> G){ typedef pair P; const int INF = 1LL << 60; priority_queue,greater

> que; vector d(G.size(),INF); //sからの最短距離 d[s] = 0; que.push({0,s}); //{最短距離,頂点} while( !que.empty() ){ P p = que.top(); que.pop(); int v = p.second; if(d[v] < p.first) continue; for(auto e : G[v]){ if(d[e.to] > d[v] + e.cost){ d[e.to] = d[v] + e.cost; que.push( {d[e.to],e.to} ); } } } return d; } signed main(){ int n, m; cin >> n >> m; vector> G(n); for(int i = 0; i < m; i++){ int s, t; cin >> s >> t; s--, t--; G[s].push_back({t, 1}); G[t].push_back({s, 1}); } int q; cin >> q; for(int i = 0; i < q; i++){ int s; cin >> s; s--; auto dp = dikstra(s, G); int friends = 0, date = 0; for(int i = 0; i < n; i++){ if(i != s && dp[i] != INF){ friends++; date = max(date, dp[i]); } } int honsitu = 0, t = 1; while(t < date){ honsitu++; t *= 2; } cout << friends << " " << honsitu << endl; } return 0; }