#include using namespace std; #define REP(i,n) for(int i=0;i<(n);i++) #define RREP(i,n) for(int i=(n-1);i>=0;i--) #define ALL(v) v.begin(),v.end() //key_t:辺固有の情報 頂点固有の情報はラムダの方でキャプチャさせる //sum_t:計算結果 template struct ReRooting{ struct Edge { int from,to; key_t cost; sum_t dp1,dp2; //dp1:部分木の内容 //dp2:e=g[idx][i]の時、g[idx][0,i)のdp1の累積が入る }; using S=function; using M=function; vector> g; const S score; const M merge; const sum_t id; vector dp1,dp2; ReRooting(int n,const S &score,const M &merge,const sum_t &id=sum_t{}) :g(n),score(score),merge(merge),id(id),dp1(n,id),dp2(n,id){} void add_edge(int u,int v,const key_t &c){ g[u].emplace_back(Edge{u,v,c,id,id}); g[v].emplace_back(Edge{v,u,c,id,id}); } void add_directed_edge(int u,int v,const key_t &c){ g[u].emplace_back(Edge{u,v,c,id,id}); } void dfs1(int idx,int pre){ for(auto &e:g[idx])if(e.to!=pre){ dfs1(e.to,idx); e.dp1=score(dp1[e.to],e); dp1[idx]=merge(dp1[idx],e.dp1); } } void dfs2(int idx,int pre,sum_t top){ sum_t now=id; for(auto &e:g[idx]){ e.dp2=now; if(e.to==pre)e.dp1=score(top,e); now=merge(now,e.dp1); } dp2[idx]=now; now=id; reverse(g[idx].begin(),g[idx].end()); for(auto &e:g[idx]){ if(e.to!=pre) dfs2(e.to,idx,merge(e.dp2,now)); now=merge(now,e.dp1); } } vector build(){ dfs1(0,-1); dfs2(0,-1,id); return dp2; } }; int main(){ int n;cin>>n; auto score=[](bool x,auto e){ return !x; }; auto merge=[](bool x,bool y){ return x&y; }; ReRooting g(n,score,merge,1); REP(_,n-1){ int u,v;cin>>u>>v;u--;v--; g.add_edge(u,v,0); } auto ans=g.build(); vector fans; REP(i,n)if(ans[i])fans.push_back(i); cout<