from collections import deque n = int(input()) g = [[] for _ in range(n)] deg = [0 for _ in range(n)] used = [False for _ in range(n)] ans = [None for _ in range(n)] for e in range(n): a, b = map(int, input().split()) a -= 1 b -= 1 if a == b: used[a] = True ans[e] = a + 1 else: g[a].append((b, e)) g[b].append((a, e)) deg[a] += 1 deg[b] += 1 dq = deque() for u in range(n): if used[u]: continue if deg[u] == 0: print("No") exit() elif deg[u] == 1: used[u] = True dq.append(u) while len(dq) > 0: cur = dq.popleft() for nxt, e in g[cur]: if not ans[e] is None: continue deg[nxt] -= 1 ans[e] = cur + 1 if used[nxt]: continue if deg[nxt] == 0: print("No") exit() elif deg[nxt] == 1: used[nxt] = True dq.append(nxt) for src in range(n): if used[src]: continue dq.append(src) used[src] = True while len(dq) > 0: cur = dq.popleft() while len(g[cur]) > 0: nxt, e = g[cur].pop() if not ans[e] is None: continue ans[e] = cur + 1 if used[nxt]: continue used[nxt] = True dq.append(nxt) break if ans.count(None) > 0: print("No") else: print("Yes") print(*ans, sep="\n")