package main import ( "fmt" "bufio" "os" ) type Cell struct { item int32 next *Cell } type CellMgr struct { top, cp, last *Cell } func (this *CellMgr) append(item int32) { ncp := new(Cell) ncp.item = item if this.top == nil { this.top = ncp this.cp = ncp this.last = ncp } else { this.last.next = ncp this.last = ncp } } func (this *CellMgr) isNext() bool { return this.cp != this.last } func (this *CellMgr) next() (int32, bool) { cp := this.cp if cp != nil { this.cp = cp.next return cp.item, true } else { return 0, false } } var N int32 var G []*CellMgr var match []int32 var used []bool func main() { r := bufio.NewReader(os.Stdin) w := bufio.NewWriter(os.Stdout) defer w.Flush() fmt.Fscan(r, &N) G = make([]*CellMgr, 2*N) match = make([]int32, 2*N) var i int32 for i = 0; i < 2*N; i++ { G[i] = new(CellMgr) match[i] = -1 } used = make([]bool, 2*N) for i = 0; i < N; i++ { var a, b int32 fmt.Fscan(r, &a, &b) add_edge(i, a + N - 1) add_edge(i, b + N - 1) } n := bipartite_matching() if n == N { fmt.Fprintln(w, "Yes") for i = 0; i < N; i++ { fmt.Fprintln(w, match[i] - N + 1) } } else { fmt.Fprintln(w, "No") } } func add_edge(u int32, v int32) { G[u].append(v) G[v].append(u) } func dfs(v int32) bool { used[v] = true for G[v].isNext() { u, _ := G[v].next() w := match[u] if w < 0 || (!used[w] && dfs(w)) { match[v] = u match[u] = v return true } } return false } func bipartite_matching() int32 { var res, v, i int32 res = 0 for v = 0; v < 2 * N; v++ { if match[v] < 0 { for i = 0; i < 2*N; i++ { used[i] = false } if dfs(v) { res++; } } } return res }