//#include #include #include using namespace std; //using namespace atcoder; using ll = long long; #define all(A) A.begin(),A.end() using vll = vector; #define rep(i, n) for (long long i = 0; i < (long long)(n); i++) using Graph = vector>; Graph G; vll E; vector seen; int main() { ll N; cin >> N; Graph G(N); vector> edge(N); vll E(N, 0); vector> SE(N); map, queue> M; rep(i, N) { ll A, B; cin >> A >> B; A--; B--; edge[i] = make_tuple(A, B, -1); M[make_pair(min(A, B), max(A, B))].push(i); SE[A].insert(B); SE[B].insert(A); } queue Q; rep(i, N) { if (SE[i].size() == 1) { Q.push(i); } else if (SE[i].size() == 0) { cout << "No" << endl; return 0; } } ll k = 0; ll j = 0; while (1) { while (!Q.empty()) { auto p = Q.front(); Q.pop(); ll n = *SE[p].begin(); ll m = M[make_pair(min(p, n), max(p, n))].front(); M[make_pair(min(p, n), max(p, n))].pop(); edge[m] = make_tuple(p, n, p); k++; SE[p].erase(SE[p].find(n)); SE[n].erase(SE[n].find(p)); if (SE[n].size() == 1) { Q.push(n); } } if (k == N) { cout << "Yes" << endl; rep(i, N) { cout << 1+get<2>(edge[i]) << endl; } return 0; } while (SE[j].size() == 0) { j++; } ll p = j; ll n = *SE[p].begin(); ll m = M[make_pair(min(p, n), max(p, n))].front(); M[make_pair(min(p, n), max(p, n))].pop(); edge[m] = make_tuple(p, n, p); k++; SE[p].erase(SE[p].find(n)); SE[n].erase(SE[n].find(p)); if (SE[n].size() == 1) { Q.push(n); } } }