#include #define ft first #define sc second #define lb lower_bound #define ub upper_bound #define pb push_back #define pt(sth) cout << sth << "\n" #define chmax(a, b) {if(ab) a=b;} #define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD using namespace std; typedef long long ll; typedef pair P; static const ll INF=1e18; static const ll MAX=1e5+7; static const ll MOD=1e9+7; class unionFind { public: vector data; unionFind(ll size) { data.assign(size, -1); } bool same(ll x, ll y) { return find(x)==find(y); } void unite(ll x, ll y) { x=find(x); y=find(y); if(x==y) return; if(data[x]>data[y]) swap(x, y); data[x]+=data[y]; data[y]=x; } ll find(ll k) { if(data[k]<0) return k; return data[k]=find(data[k]); } ll size(ll k) { return -data[find(k)]; } }; ll N, M; vector g[MAX]; ll d[MAX]; void dijkstra(ll s) { ll i, u; ll clr[MAX]; for(i=0; i q; q.push(P(0, s)); d[s]=0; while(q.size()) { P f=q.top(); q.pop(); u=f.sc; clr[u]=1; if(d[u]<-f.ft) continue; for(i=0; id[u]+1) { d[v]=d[u]+1; q.push(P(-d[v], v)); } } } } int main(void) { cin >> N >> M; ll i, j; unionFind uf(N); for(i=0; i> a >> b; a--; b--; g[a].pb(b); g[b].pb(a); uf.unite(a, b); } ll Q; cin >> Q; for(i=0; i> a; a--; dijkstra(a); ll max=1; for(j=0; jpow(2, t)) t++; pt(uf.size(a)-1 << " " << t); } }