import java.util.*
fun main(args: Array<String>){
	val cin = Scanner(System.`in`)
    val n = cin.nextInt()
    val k = cin.nextInt()

    val connect = Array<MutableList<Int>>(n, { mutableListOf() })
    val parent = Array<Int>(n, { -1 })

    for (i in 0..n-2) {
        val a = cin.nextInt() - 1
        val b = cin.nextInt() - 1
        connect[a].add(b)
        connect[b].add(a)
    }

    var now = -1
    val queue: MutableList<Int> = mutableListOf(0)
    var ans: Long = k.toLong()
    var mod = 1000000007

    while (queue.size != 0) {
        now = queue.removeAt(0)
        var i = 1
        if (now != 0) {
            i += 1
        }
        for (c in connect[now]) {
            if (c != parent[now]) {
                queue.add(c)
                parent[c] = now
                ans = ans*((k - i).toLong()) % mod
                i += 1
            }
        }
    }
    println(ans)
}