#include #define REP(i,n) for(int i=0;i<(n);i++) #define ALL(v) (v).begin(),(v).end() #define SZ(x) ((int)(x).size()) #define int long long using namespace std; typedef vector vint; typedef pair pint; const int size=100010; const int INF=1e9; vint G[size]; int N,M; int calc(int dist) { if(dist==1) return 0; return calc((dist+1)/2)+1; } void bfs(int s) { vint dist(N); REP(i,N) dist[i]=INF; dist[s]=0; queue Q; Q.push(s); while(!Q.empty()){ int v=Q.front(); Q.pop(); for(int u:G[v]){ if(dist[u]!=INF) continue; dist[u]=dist[v]+1; Q.push(u); } } int cnt=0,day=0; REP(i,N){ if(dist[i]!=INF and dist[i]>0){ cnt++; int d=calc(dist[i]); day=max(day,d); } } cout<>N>>M; REP(i,M){ int a,b; cin>>a>>b; a--; b--; G[a].push_back(b); G[b].push_back(a); } int Q; cin>>Q; while(Q--){ int q; cin>>q; q--; bfs(q); } }