class Integer
  def combination(k)
    return 1 if k.zero?

    (self - k + 1 .. self).inject(:*) / k.factorial
  end

  def permutation(k)
    return 1 if k.zero?

    (self - k + 1 .. self).inject(:*)
  end

  def factorial
    return 1 if self.zero?

    (1 .. self).inject(:*)
  end
end


def dfs(v, p = -1)
  $to[v].each do |u|
    next if u == p
    dfs(u, v)
  end
  nk   = (p == -1) ? $k : $k - 2
  c    = (p == -1) ? $to[v].size + 1 : $to[v].size - 1
  $ans *= nk.permutation(c)
end

$to  = Array.new(10005) { Array.new }
$ans = 1

def main
  n, $k = gets.split.map(&:to_i)
  (0 ... n - 1).each do
    a, b = gets.split.map(&:to_i).map(&:pred)
    $to[a].push(b)
    $to[b].push(a)
  end
  puts dfs(0) % 1_000_000_007
end

main