N = gets.to_i $G = Array.new(N*2) {Array.new} $match = Array.new(N*2, -1) def add_edge(u, v) $G[u] << v $G[v] << u end def dfs(v) $used[v] = true $G[v].each {|u| w = $match[u] if w < 0 or (not $used[w] and dfs(w)) then $match[v] = u $match[u] = v return true end } return false end def bipartite_matching res = 0 0.upto(2*N-1) {|v| if $match[v] < 0 then $used = Array.new(N*2, false) if dfs(v) then res += 1 end end } return res end 0.upto(N-1) { |i| a, b = gets.split(" ").map{|s| s.to_i} add_edge(i, a + N - 1) add_edge(i, b + N - 1) } n = bipartite_matching if n == N then puts "Yes" 0.upto(N-1) {|i| puts $match[i] - N + 1 } else puts "No" end