#include typedef struct List { struct List *next; int v, id; } list; int main() { int i, N, M, u, w, deg[100001] = {}; list *adj[100001] = {}, e[200001], *p; scanf("%d", &N); for (i = 0; i < N; i++) { scanf("%d %d", &u, &w); e[i*2].v = w; e[i*2+1].v = u; e[i*2].id = i + 1; e[i*2+1].id = i + 1; e[i*2].next = adj[u]; e[i*2+1].next = adj[w]; adj[u] = &(e[i*2]); adj[w] = &(e[i*2+1]); deg[u]++; deg[w]++; } for (u = 1; u <= N; u++) if (deg[u] == 0) break; if (u <= N) { printf("No\n"); fflush(stdout); return 0; } int x, flag[100001] = {}, ans[100001] = {}, q[100001], head, tail = 0; for (u = 1; u <= N; u++) if (deg[u] == 1) q[tail++] = u; for (head = 0; head < tail; head++) { u = q[head]; for (p = adj[u]; p != NULL; p = p->next) { w = p->v; i = p->id; if (ans[i] == 0) { ans[i] = u; flag[u] = 1; deg[w]--; if (deg[w] == 1) q[tail++] = w; } } } if (tail < N) { for (x = 1; x <= N; x++) { if (deg[x] <= 1) continue; for (p = adj[x]; p != NULL; p = p->next) { u = p->v; i = p->id; if (ans[i] == 0) { ans[i] = x; flag[x] = 1; deg[u]--; break; } } for (; u != x; u = w) { for (p = adj[u]; p != NULL; p = p->next) { w = p->v; i = p->id; if (ans[i] == 0) { ans[i] = u; flag[u] = 1; deg[w]--; break; } } if (p == NULL) break; } } } for (u = 1; u <= N; u++) if (flag[u] == 0) break; if (u <= N) printf("No\n"); else { printf("Yes\n"); for (i = 1; i <= N; i++) printf("%d\n", ans[i]); } fflush(stdout); return 0; }