class UnionFind: def __init__(self, n): self.par = [-1]*n self.rank = [0]*n def Find(self, x): if self.par[x] < 0: return x else: self.par[x] = self.Find(self.par[x]) return self.par[x] def Unite(self, x, y): x = self.Find(x) y = self.Find(y) if x != y: if self.rank[x] < self.rank[y]: self.par[y] += self.par[x] self.par[x] = y else: self.par[x] += self.par[y] self.par[y] = x if self.rank[x] == self.rank[y]: self.rank[x] += 1 def Same(self, x, y): return self.Find(x) == self.Find(y) def Size(self, x): return -self.par[self.Find(x)] import sys import io, os input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline from collections import Counter, deque, defaultdict n = int(input()) uf = UnionFind(n) E = [] for i in range(n): a, b = map(int, input().split()) a, b = a-1, b-1 uf.Unite(a, b) E.append((a, b)) C = Counter() for a, b in E: C[uf.Find(a)] += 1 for k, v in C.items(): if v != uf.Size(k): print('No') exit() uf = UnionFind(n) stack = [] ans = [-1]*n g = [[] for i in range(n)] visit = [False]*n for i, (a, b) in enumerate(E): if uf.Same(a, b): stack.append(a) ans[i] = a visit[a] = True else: uf.Unite(a, b) g[a].append((b, i)) g[b].append((a, i)) while stack: v = stack.pop() for u, i in g[v]: if visit[u]: continue ans[i] = u stack.append(u) visit[u] = True print('Yes') ans = [i+1 for i in ans] print(*ans, sep='\n')