#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(int i=0;i<(int)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) int main(){ int n;cin>>n; vcv(n); rep(i,n)cin>>v[i].fi>>v[i].se; rep(i,n)v[i].fi--,v[i].se--; vc vx(n,vc(0)); dsu d(n); vcbo(n,false); rep(i,n){ auto [a,b]=v[i]; if(!d.same(a,b)){ d.merge(a,b),bo[i]=true; vx[a].pb({b,i}); vx[b].pb({a,i}); } } vcans(n,-1); auto f=[&](auto f,int a,int p)->void{ for(auto [au,i]:vx[a])if(au!=p){ ans[i]=au; f(f,au,a); } return; }; vcok(n,0); rep(i,n)if(!bo[i]){ auto [a,b]=v[i]; if(ok[d.leader(a)])continue; ok[d.leader(a)]=1; ans[i]=a; f(f,a,-1); } rep(i,n)if(ans[i]==-1){ cout<<"No"; return 0; } cout<<"Yes"<<"\n"; rep(i,n)cout<