#include using namespace std; #define ALL(x) x.begin(),x.end() #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b vector dijkstra(int s,vector>> &G){ const T TINF=numeric_limits::max(); using P=pair; int n=G.size(); vector d(n,TINF); vector b(n,-1);//previous point priority_queue,greater

> q; d[s]=0; q.emplace(d[s],s); while(!q.empty()){ P p=q.top();q.pop(); int v=p.second; if(d[v]d[v]+c){ d[u]=d[v]+c; b[u]=v; q.emplace(d[u],u); } } } return d; } signed main(){ cin.tie(0); ios::sync_with_stdio(0); int n,m;cin>>n>>m; vector> g(n); rep(i,m){ int u,v;cin>>u>>v;u--,v--; g[u].push_back(v); g[v].push_back(u); } int q;cin>>q; while(q--){ int st;cin>>st;st--; queue que; vector dis(n,-1); dis[st]=0; que.push(st); int cnt=0; while(!que.empty()){ int cur=que.front();que.pop(); for(auto to:g[cur]){ if(dis[to]>=0) continue; dis[to]=dis[cur]+1; cnt++; que.push(to); } } int mx=0; rep(i,n)chmax(mx,dis[i]); mx--; int ans=0; while(mx>0){ ans++; mx>>=1; } cout<