#include using namespace std; using uint = unsigned int; using ll = long long; using ull = unsigned long long; template using V = vector; template using VV = V>; template using VVV = V>; template using VVVV = VV>; #define rep(i,n) for(ll i=0ll;i void chmin(T& t, const U& u) { if (t > u) t = u; } template void chmax(T& t, const U& u) { if (t < u) t = u; } // cin.tie(nullptr); // ios::sync_with_stdio(false); // cout << fixed << setprecision(20); void solve(){ ll n; cin >> n; VV G(n); rep(i,n-1){ ll a,b; cin >> a >> b; a--; b--; G[a].eb(b); G[b].eb(a); } V dist(n, INF); dist[0] = 0; queue que; que.push(0); while(!que.empty()){ ll nd = que.front(); que.pop(); all(nx, G[nd]) if(dist[nx]>dist[nd]+1){ dist[nx] = dist[nd]+1; que.push(nx); } } ll x = 0; rep(i, n) if(dist[x]dist[nd]+1){ dist[nx] = dist[nd]+1; que.push(nx); } } x = 0; rep(i, n) if(dist[x]> t; rep(i,t) solve(); }