import sys input = sys.stdin.readline N = int(input()) class BipartiteMatching: def __init__(self, n, m): self._n = n self._m = m self._to = [[] for _ in range(n)] def add_edge(self, a, b): self._to[a].append(b) def solve(self): n, m, to = self._n, self._m, self._to pre = [-1] * n root = [-1] * n p = [-1] * n q = [-1] * m upd = True while upd: upd = False s = [] s_front = 0 for i in range(n): if p[i] == -1: root[i] = i s.append(i) while s_front < len(s): v = s[s_front] s_front += 1 if p[root[v]] != -1: continue for u in to[v]: if q[u] == -1: while u != -1: q[u] = v p[v], u = u, p[v] v = pre[v] upd = True break u = q[u] if pre[u] != -1: continue pre[u] = v root[u] = root[v] s.append(u) if upd: for i in range(n): pre[i] = -1 root[i] = -1 return [(v, p[v]) for v in range(n) if p[v] != -1] dinic = BipartiteMatching(N, N) for i in range(N): u, v = map(int, input().split()) u -= 1 v -= 1 dinic.add_edge(i, u) dinic.add_edge(i, v) flow = dinic.solve() if len(flow) == N: print("Yes") for _, x in flow: print(x + 1) else: print("No")