MOD = 1_000_000_007
N,K = gets.split(' ').map(&:to_i)
trees = {}
(1..N).each do |i|
  trees[i] = []
end
(N-1).times do
  a,b = gets.split(' ').map(&:to_i)
  trees[a].push(b)
  trees[b].push(a)
end

nodes = []
visited = {1 => true}
# root
ans = K
# 1層目
count = K-1
trees[1].each do |id|
  ans *= count
  ans % MOD
  nodes.push(trees[id])
  visited[id] = true
  count -= 1
end
# 2層目
nodes.each do |tree|
  count = K-2
  tree.each do |id|
    next if visited[id]
    ans *= count
    ans %= MOD
    nodes.push(trees[id])
    visited[id] = true
    count -= 1
  end
end
p ans