import scala.io.StdIn.readLine import scala.collection.mutable.ArrayBuffer @main def yuki196(): Unit = val MOD = 1000000007L val Array(n, k) = readLine.split(" ").map(_.toInt) val graph = Array.fill(n)(ArrayBuffer[Long]()) for _ <- 1 until n do val Array(u, v) = readLine.split(" ").map(_.toInt) graph(u).append(v) graph(v).append(u) val visited = Array.fill(n)(false) val size = Array.fill(n)(0) val dp = Array.fill(n)(ArrayBuffer[Long]()) def dfs(cur: Long): Unit = visited(cur.toInt) = true size(cur.toInt) = 1 var dpCur: ArrayBuffer[Long] = ArrayBuffer(1) for next <- graph(cur.toInt) if !visited(next.toInt) do dfs(next) val dpNext = dp(next.toInt) val ndp = ArrayBuffer.fill(size(cur.toInt) + size(next.toInt) - 1)(0L) for i <- dpCur.indices j <- dpNext.indices do ndp(i + j) = (ndp(i + j) + dpCur(i) * dpNext(j)) % MOD dpCur = ndp size(cur.toInt) += size(next.toInt) - 1 dpCur.append(1) size(cur.toInt) += 1 dp(cur.toInt) = dpCur dfs(0) println(dp(0)(k))