// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN reverse replace stringstream string::npos length substr front priority_queue
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#include <bits/stdc++.h>
usingnamespace std;
#define debug(...) 42
#endif
#define ll long long
#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
const ll sz =300119;
std::vector<ll> adj[sz];
ll dep[sz], di;
vector<ll>d1(sz, 0), el, vis(sz, 0), d2(sz, 0), d3(sz, 0);
ll dfs(ll u , ll h){
vis[u]=1;
d1[u]= h;
ll f =0, s =0;
for(auto v : adj[u]){
if(!vis[v]){
ll sub = dfs(v, h +1);
f = max(sub, f);
if(f > s) swap(f, s);
}
}
d2[u]= f, d3[u]= s;
di = max({di, d2[u]+ d3[u]});
return max(1LL + d2[u], 1LL + d3[u]);
}
void bfs(ll u , ll h =0){
vis[u]=1;
debug(u, h);
if((adj[u].size()==1) and h) el.push_back(u);
for(auto v : adj[u]){
if(!vis[v]){
ll z = max(d2[v], d3[v])+1;
if(z == di){
el.push_back(u);
bfs(v, 1);
}elseif(d2[u]+ d3[u]== di and (z == d2[u] or z == d3[u])){