import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.Map
import scala.collection.mutable.Queue
import scala.collection.mutable.PriorityQueue

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, K = in.next().toInt
  val tree = Array.fill[List[Int]](N+1)(Nil)
  for (_ <- 1 until N) {
    val a, b = in.next().toInt
    tree(a) = b :: tree(a)
    tree(b) = a :: tree(b)
  }  


  //
  val MOD = 1e9.toInt + 7
  val mc = new ModComb(1e5.toInt, MOD)

  val dp = new Array[Boolean](N+1)
  var ans = 1L


  val first = 1 + tree(1).length
  if (first > K)
    ans = 0
  else {
    ans = mc.perm(K, first)

    breakable {
      val q = new Queue[Int]()

      dp(1) = true
      for (e <- tree(1))
        q.enqueue(e)


      while(!q.isEmpty) {
        val i = q.dequeue()
        dp(i) = true

        val k = tree(i).length - 1
        if(k > K-2) {
          ans = 0
          break
        }
        ans *= mc.perm(K-2, k)
        ans %= MOD
        for (e <- tree(i) if !dp(e))
          q.enqueue(e)
      }
    }
  }

  println(ans)
}


class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  private val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  private val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nPk
  def perm(n: Int, k: Int): Long = {
    (fact(n) * factInv(n-k)) % mod
  }


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


class InputReader(stream: InputStream) {
  private val reader = new BufferedReader(new InputStreamReader(stream))
  private var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}
