import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 from collections import * # __dfsのflow_to_meの初期値がinfに相当するか注意 # n頂点,sスタート,tゴール class Dinic: def __init__(self, n, s, t): self.n, self.s, self.t = n, s, t self.to = [[] for _ in range(n)] self.max_flow = -1 def add_edge(self, u, v, cap): u_index_in_to_v = len(self.to[v]) v_index_in_to_u = len(self.to[u]) self.to[u].append([v, cap, u_index_in_to_v]) self.to[v].append([u, 0, v_index_in_to_u]) # 無向辺の追加 def add_undir_edge(self, u, v, cap): u_index_in_to_v = len(self.to[v]) v_index_in_to_u = len(self.to[u]) self.to[u].append([v, cap, u_index_in_to_v]) self.to[v].append([u, cap, v_index_in_to_u]) def __set_level(self): s = self.s level = [-1] * self.n level[s] = 0 q = deque() q.append([s, 0]) while q: u, u_level = q.popleft() for v, cap, _ in self.to[u]: if cap == 0: continue if level[v] != -1: continue level[v] = u_level + 1 if v == self.t: self.level = level return True q.append([v, u_level + 1]) return False def __dfs(self, u=-1, flow_to_me=10 ** 16): if u == -1: u = self.s if u == self.t: return flow_to_me flow_from_me = 0 u_level = self.level[u] for utov_i, (v, cap, vtou_i) in enumerate(self.to[u]): if self.level[v] != u_level + 1: continue if cap == 0: continue flow_to_v = self.__dfs(v, min(cap, flow_to_me - flow_from_me)) if not flow_to_v: continue flow_from_me += flow_to_v self.to[u][utov_i][1] -= flow_to_v self.to[v][vtou_i][1] += flow_to_v return flow_from_me def __calculation(self): res = 0 while self.__set_level(): res += self.__dfs() return res # これが出力用 def get_max_flow(self): if self.max_flow == -1: self.max_flow = self.__calculation() return self.max_flow n = II() mf = Dinic(2*n+2,2*n,2*n+1) for i in range(n): a, b = LI1() mf.add_edge(2*n, i, 1) mf.add_edge(i, a+n, 1) mf.add_edge(i, b+n, 1) mf.add_edge(i+n, 2*n+1, 1) mx = mf.get_max_flow() ans = [0]*n if mx == n: print("Yes") for u in range(n): for v,c,_ in mf.to[u]: if v<2*n and c==0: ans[u]=v-n+1 # if e.src < n and e.flow: # ans[e.src] = e.dst-n+1 print(*ans, sep="\n") else: print("No")