#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; using namespace std; using ll=long long; using ull=unsigned long long; using P=pair; templateusing minque=priority_queue,greater>; templatebool chmax(T &a,const T &b){return (abool chmin(T &a,const T &b){return (a>b?(a=b,true):false);} template ostream &operator<<(ostream &os,const pair&p){ os< istream &operator>>(istream &is,pair&p){ is>>p.first>>p.second; return is; } template istream &operator>>(istream &is,vector &a){ for(auto &i:a)is>>i; return is; } #define reps(i,a,n) for(int i=(a);i<(n);i++) #define rep(i,n) reps(i,0,n) #define all(x) x.begin(),x.end() ll myceil(ll a,ll b){return (a+b-1)/b;} int n; vector>to; vectordp,ans; void dfs(int x,int p){ dp[x]=true; for(auto i:to[x]){ if(i==p)continue; dfs(i,x); if(dp[i])dp[x]=false; } } void dfs2(int x,int p){ ans[x]=true; for(auto i:to[x])if(dp[i])ans[x]=false; int s=to[x].size(); vectorlft(s),rht(s); rep(i,s)lft[i]=rht[i]=dp[to[x][i]]; reps(i,1,s)lft[i]=lft[i]||lft[i-1]; for(int i=s-2;i>=0;i--)rht[i]=rht[i]||rht[i+1]; rep(i,s){ if(to[x][i]==p)continue; dp[x]=true; if(0>n; to.resize(n); rep(i,n-1){ int a,b; cin>>a>>b; a--,b--; to[a].push_back(b); to[b].push_back(a); } dp.resize(n),ans.resize(n); dfs(0,-1); dfs2(0,-1); vectorid; rep(i,n)if(ans[i])id.push_back(i+1); cout<