import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import java.lang.Double.parseDouble as parseDoubleJVM
import java.lang.Integer.parseInt as parseIntJVM
import java.lang.Long.parseLong as parseLongJVM

fun main(args: Array<String>) = yorukatsu14e()

fun yorukatsu14e() = IO_yorukatsu14e().exec {
    val n = readInt()
    val k = readLong()

    val graph = IntArray(n)
    repeat(n - 1) {
        val from = readInt() - 1
        val to = readInt() - 1
        graph[from]++
        graph[to]++
    }

    var answer = k

    for ((index, r) in graph.withIndex()) {
        val n1 = if (index == 0) k - 1 else k - 2
        val r1 = if (index == 0) r else r - 1
        for (p in n1 downTo n1 - r1 + 1) {
            answer *= p
            answer %= MOD
        }
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

@Suppress("unused", "ClassName", "SpellCheckingInspection")
class IO_yorukatsu14e {
    val br = BufferedReader(InputStreamReader(System.`in`))
    var st = StringTokenizer("")
    val pw = PrintWriter(System.out)

    fun readString(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
        return st.nextToken()!!
    }

    fun readInt() = parseIntJVM(readString())
    fun readLong() = parseLongJVM(readString())
    fun readDouble() = parseDoubleJVM(readString())

    //    fun readStringList(size: Int) = readList(size) { readString() }
    //    fun readIntList(size: Int) = readList(size) { readInt() }
    //    fun readLongList(size: Int) = readList(size) { readLong() }
    //    fun readDoubleList(size: Int) = readList(size) { readDouble() }
    fun readIntArray(size: Int) = IntArray(size) { readInt() }
    fun readLongArray(size: Int) = LongArray(size) { readLong() }
    fun readDoubleArray(size: Int) = DoubleArray(size) { readDouble() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }

    //    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }
    fun readLine() = br.readLine()!!
    fun println() = pw.println()
    fun print(o: Any?) = pw.print(o)
    fun println(o: Any?) = pw.println(o)
    inline fun exec(code: IO_yorukatsu14e.() -> Unit) {
        code()
        pw.flush()
    }
}
