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