#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>> G(N); vector deg(N, 0); rep(i,N) { int a,b; cin >> a >> b; a--; b--; G[a].push_back({b, i}); G[b].push_back({a, i}); deg[a]++, deg[b]++; } priority_queue,vector>,greater>> pq; rep(i,N) pq.push({deg[i], i}); vector ans(N, -1), used(N, 0); while(!pq.empty()) { auto [d, v] = pq.top(); pq.pop(); if(d == deg[v] && !used[v]) { for(auto [to, id] : G[v]) { if(ans[id] == -1) { ans[id] = v; used[v] = 1; deg[v]--, deg[to]--; pq.push({deg[v], v}); pq.push({deg[to], to}); break; } } } } rep(i,N) { if(used[i] == 0) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; rep(i,N) cout << ans[i] + 1 << "\n"; }