#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N; cin >> N; vector A(N), B(N); map,int> exist; rep(i,N) cin >> A[i] >> B[i], A[i]--, B[i]--, exist[{A[i], B[i]}] = exist[{B[i], A[i]}] = 1; vector> G(N); vector deg(N, 0); rep(i,N) { G[A[i]].push_back(B[i]); G[B[i]].push_back(A[i]); deg[A[i]]++, deg[B[i]]++; } queue q; vector used(N, 0); rep(i,N) if(deg[i] == 1) { q.push(i); deg[i] -= 1; used[i] = 1; } map,int> ans; while(!q.empty()) { int v = q.front(); q.pop(); for(int to : G[v]) { if(!used[to]) { ans[{v, to}] = ans[{to, v}] = v; if(--deg[to] == 1) { q.push(to); used[to] = 1; } } } } rep(i,N) if(!used[i]) { vector vs; function dfs = [&](int v) -> void { vs.push_back(v); used[v] = 1; for(int to : G[v]) if(!used[to]) dfs(to); }; dfs(i); if(vs.size() == 1u) { if(exist[{i, i}]) { ans[{i, i}] = i; } else { cout << "No" << endl; return 0; } } rep(k,vs.size()) ans[{vs[k], vs[(k + 1) % (int)vs.size()]}] = vs[k]; } cout << "Yes" << endl; rep(i,N) { cout << ans[{A[i], B[i]}] + 1 << "\n"; ans[{A[i], B[i]}] ^= (A[i] ^ B[i]); } }