#include #include #include #include using namespace std; using i32 = int32_t; using i64 = int64_t; #define rep(i,n) for(int i=0; i<(n); i++) int N; vector>> E; vector used; int main(){ cin >> N; E.resize(N); vector I(N,0); rep(i,N){ int a,b; cin >> a >> b; a--; b--; E[a].push_back({b,i}); E[b].push_back({a,i}); I[a]++; I[b]++; } used.assign(N,-1); vector q; rep(i,N) if(I[i] == 1) q.push_back(i); rep(i,q.size()){ int p = q[i]; for(auto e : E[p]) if(used[e.second] == -1){ used[e.second] = p; I[e.first]--; if(I[e.first] == 1){ q.push_back(e.first); break; } } I[p]--; } rep(s,N) if(I[s] >= 2){ int to = -1; I[s]--; for(auto e : E[s]) if(used[e.second] == -1){ used[e.second] = s; to = e.first; I[e.first]--; break; } if(to == -1){ cout << "No\n"; return 0; } while(to != -1){ int p = to; I[p]--; to = -1; for(auto e : E[p]) if(used[e.second] == -1){ used[e.second] = p; to = e.first; I[e.first]--; break; } } } rep(i,N) if(used[i] == -1){ cout << "No\n"; return 0; } vector filled(N,0); rep(i,N) filled[used[i]] = 1; rep(i,N) if(filled[i] == 0){ cout << "No\n"; return 0; } cout << "Yes\n"; rep(i,N) cout << (used[i]+1) << "\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;