#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 1000000007; struct UnionFind { vectorpar, vsize, esize; UnionFind(int sz_) : par(sz_), vsize(sz_, 1), esize(sz_, 0) { for (int i = 0; i < sz_; i++)par[i] = i; } void init(int sz_) { par.resize(sz_); vsize.resize(sz_, 1); esize.resize(sz_, 0); for (int i = 0; i < sz_; i++)par[i] = i; } int root(int x) { if (par[x] == x)return x; else return par[x] = root(par[x]); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) { esize[x]++; return false; } if (vsize[x] < vsize[y])swap(x, y); vsize[x] += vsize[y]; esize[x] += esize[y] + 1; par[y] = x; return true; } bool issame(int x, int y) { return root(x) == root(y); } int vs(int x) { return vsize[root(x)]; } int es(int x) { return esize[root(x)]; } }; signed main() { ios::sync_with_stdio(false); cin.tie(0); int N; cin >> N; UnionFind uf(N); vectorA(N), B(N); for (int i = 0; i < N; i++) { int a, b; cin >> a >> b; a--; b--; uf.merge(a, b); A[i] = a + 1; B[i] = b + 1; } int cnt = 0; for (int i = 0; i < N; i++) { if (uf.root(i) == i)cnt += min(uf.vs(i), uf.es(i)); } if (cnt != N) { cout << "No" << endl; return 0; } cout << "Yes" << endl; mapmp, c; for (int i = 0; i < N; i++) { mp[A[i]]++; mp[B[i]]++; c[A[i]]++; c[B[i]]++; } for (int i = 0; i < N; i++) { if (mp[A[i]] == 1 && mp[A[i]] != c[A[i]]) { cout << A[i] << endl; mp[A[i]]--; } else if(mp[B[i]] == 1 && mp[A[i]] != c[A[i]]){ cout << B[i] << endl; mp[B[i]]--; } else if (mp[A[i]] == 0) { cout << B[i] << endl; mp[B[i]]--; } else if (mp[B[i]] == 0) { cout << A[i] << endl; mp[A[i]]--; } else { cout << A[i] << endl; mp[A[i]]--; } } return 0; }