import sys input = sys.stdin.buffer.readline sys.setrecursionlimit(10 ** 7) class BipartiteMatching: def __init__(self, N, M): self.N = N self.M = M self.pairA = [-1] * N self.pairB = [-1] * M self.edge = [[] for _ in range(N)] self.was = [0] * N self.iter = 0 def add(self, s, t): self.edge[s].append(t) def _DFS(self, s): self.was[s] = self.iter for t in self.edge[s]: if self.pairB[t] == -1: self.pairA[s] = t self.pairB[t] = s return True for t in self.edge[s]: if self.was[self.pairB[t]] != self.iter and self._DFS(self.pairB[t]): self.pairA[s] = t self.pairB[t] = s return True return False def solve(self): res = 0 while True: self.iter += 1 found = 0 for i in range(self.N): if self.pairA[i] == -1 and self._DFS(i): found += 1 if not found: break res += found return res N = int(input()) match = BipartiteMatching(N, N) for i in range(N): a, b = map(int, input().split()) a -= 1 b -= 1 match.add(i, a) match.add(i, b) pair = match.solve() if pair < N: print("No") exit() print("Yes") for x in match.pairA: print(x+1)