data class Node ( val id: Int, var col: Int, val ngh: ArrayList = ArrayList() ){ fun colorize(c: Int): Boolean { // println("$id -> $c") if(col > 0) return col == c col = c for(x in ngh){ x.colorize(3 - c) } return true } } class Graph(N: Int) { val nodes = ArrayList() init { for (i in 0 until N) { nodes.add(Node(i, 0)) } } fun join(a:Int, b:Int){ nodes[a].ngh.add(nodes[b]) nodes[b].ngh.add(nodes[a]) } } fun main(args : Array) { val N = readLine()!!.toInt() val g = Graph(N) val seen = HashSet() val leaves = HashSet() for(t in 1 until N) { val (a, b) = readLine()!!.split(" ").map { it.toInt() - 1} g.join(a, b) if(a in seen)leaves.remove(a) else leaves.add(a) if(b in seen)leaves.remove(b) else leaves.add(b) seen.add(a) seen.add(b) } var ok = true for(x in leaves) { ok = ok && g.nodes[x].colorize(1) } println(if(ok)"Yes" else "No") }