#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } struct Namori{ int n; vector> g; vector deg; vector> v; Namori(int _n,vector _x,vector _y) { n=_n; g.resize(n); deg.resize(n); v.resize(n); for(int i=0;i<_x.size();i++){ g[_x[i]].emplace_back(_y[i]); g[_y[i]].emplace_back(_x[i]); deg[_x[i]]++; deg[_y[i]]++; } for(int i=0;i q; vector done(n); for(int i=0;ivoid{ v[s]={v[p].first+1,v[p].second}; for(int t:g[s]){ if(t==p)continue; dfs(dfs,t,s); } }; for(int i=0;i> n; vector x(n),y(n); for(int i=0;i> x[i] >> y[i]; if(n < x[i] and n < y[i]){ printf("No\n"); return 0; } if(n < x[i]){ x[i]=y[i]; } if(n < y[i]){ y[i]=x[i]; } x[i]--; y[i]--; } Namori na(n,x,y); if(!na.build()){ printf("No\n"); return 0; } printf("Yes\n"); vector ok(n); auto v=na.v; for(int i=0;iv[y[i]].first){ printf("%d\n",x[i]+1); ok[x[i]]=1; } else if(v[x[i]].first