def main(): import sys input = sys.stdin.read().split() idx = 0 n = int(input[idx]) idx += 1 pairs = [] for _ in range(n): a = int(input[idx]) b = int(input[idx + 1]) pairs.append((a, b)) idx += 2 used = [False] * (n + 1) res = [0] * n # Process in reverse order (i from n-1 downto 0) for i in range(n-1, -1, -1): a, b = pairs[i] if not used[a] and not used[b]: # Choose the one that appears first; arbitrary choice to prefer a res[i] = a used[a] = True elif not used[a]: res[i] = a used[a] = True elif not used[b]: res[i] = b used[b] = True else: # Both are used, choose any (here a) res[i] = a # Check if all are used all_used = all(used[1:n+1]) if not all_used: print("No") else: print("Yes") for num in res: print(num) if __name__ == "__main__": main()