#include #define rep(i,n) for(int i = 0; i < (int)(n); i++) using namespace std; using LL = long long; using P = pair; using vv = vector>; const int INF = (int)1e9; const LL LINF = (LL)1e18; const int Max_N = (int)1e5; class UnionFind { public: vector par; vector siz; UnionFind(long long sz_): par(sz_), siz(sz_, (long long)1) { for (long long i = 0; i < sz_; ++i) par[i] = i; } void init(long long sz_) { par.resize(sz_); siz.assign(sz_, (long long)1); for (long long i = 0; i < sz_; ++i) par[i] = i; } long long root(long long x) { while (par[x] != x) { x = par[x] = par[par[x]]; } return x; } bool unite(long long x, long long y) { x = root(x); y = root(y); if (x == y) return false; if (siz[x] < siz[y]) swap(x, y); siz[x] += siz[y]; par[y] = x; return true; } bool same(long long x, long long y) { return root(x) == root(y); } long long size(long long x) { return siz[root(x)]; } }; struct edge{ int to, num; edge(int to, int num) : to(to), num(num) {} }; vector> G; bool visited[100010]; int ans[100010]; void dfs(int n, int par = -1){ for(auto e : G[n]){ if(e.to == par) continue; ans[e.num] = e.to + 1; dfs(e.to, n); } } void cycle(int n, int edge_prev = -1){ int st = -1; visited[n] = 1; for(int j = 0; j < G[n].size(); j++){ edge e = G[n][j]; if(e.num == edge_prev) continue; if(visited[e.to]){ st = e.to; ans[e.num] = e.to + 1; G[n].erase(G[n].begin() + j); continue; } cycle(e.to, e.num); } dfs(st); } int main(){ int N; cin >> N; G.resize(N); assert(1 <= N and N <= Max_N); vector A(N); UnionFind uf(N); rep(i,N){ int a, b; cin >> a >> b; assert(1 <= a and a <= N); assert(1 <= b and b <= N); a--; b--; uf.unite(a, b); A[i] = a; G[a].emplace_back(b, i); G[b].emplace_back(a, i); } vector edge_num(N); rep(i,N){ int p = uf.root(A[i]); edge_num[p]++; } rep(i,N){ if(uf.root(i) != i) continue; int siz = uf.size(i); if(siz != edge_num[i]){ cout << "No" << endl; return 0; } } rep(i,N) if(!visited[i]) cycle(i); cout << "Yes" << endl; rep(i,N) cout << ans[i] << endl; return 0; }