import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import kotlin.properties.Delegates
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()
    k = readInt()

    graph = Array(n) { mutableSetOf<Int>() }
    repeat(n - 1) {
        val from = readInt() - 1
        val to = readInt() - 1
        graph!![from].add(to)
        graph!![to].add(from)
    }

    biCoef = BiCoef(k + 1)

    val answer = k.toLong() * dfs(0, -1) % MOD

    println(answer)
}

private var k by Delegates.notNull<Int>()
private var graph: Array<MutableSet<Int>>? = null
private var biCoef: BiCoef? = null

private fun dfs(currIndex: Int, beforeIndex: Int): Long {
    var sum = 1L
    val n1 = if (currIndex == 0) k - 1 else k - 2
    val r = if (currIndex == 0) graph!![currIndex].size else graph!![currIndex].size - 1
    sum *= biCoef!!.nPr(n1, r)
    sum %= MOD
    return sum * graph!![currIndex].filterNot { it == beforeIndex }.map { dfs(it, currIndex) }
        .fold(1L) { acc, l -> acc * l % MOD } % MOD
}

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

@Suppress("unused")
private class BiCoef(max: Int) {
    private val fact = LongArray(max + 1)
    private val fInv = LongArray(max + 1)
    private val inv = LongArray(max + 1)

    init {
        fact[0] = 1
        fact[1] = 1
        fInv[0] = 1
        fInv[1] = 1
        inv[1] = 1
        for (i in 2..max) {
            fact[i] = fact[i - 1] * i % MOD
            inv[i] = MOD - inv[(MOD % i).toInt()] * (MOD / i) % MOD
            fInv[i] = fInv[i - 1] * inv[i] % MOD
        }
    }

    fun fact(n: Int): Long = if (n < 0) 0 else fact[n]
    fun inv(n: Int): Long = if (n < 0) 0 else inv[n]
    fun fInv(n: Int): Long = if (n < 0) 0 else fInv[n]
    fun comb(n: Int, k: Int): Long = nCr(n, k)
    fun nCr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * (fInv[k] * fInv[n - k] % MOD) % MOD
    fun perm(n: Int, k: Int): Long = nPr(n, k)
    fun nPr(n: Int, k: Int): Long = if (n < k || n < 0 || k < 0) 0 else fact[n] * fInv[n - k] % MOD % MOD
}

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

    fun readString() = run { while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }
        .run { 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) = run { code() }.run { pw.flush() }
}


Measured memory_bytes: 105844