MOD = 1000000007
n, k = gets.chomp.split.map(&:to_i)
path = Array.new(n+1){ [] }
(n-1).times do
  a, b = gets.chomp.split.map(&:to_i)
  path[a] << b
  path[b] << a
end

queue = [[1,0,0]]
done = []

ans = 1
while q = queue.shift do
  node, dist1, dist2 = q
  done[node] = true
  ans = ans * (k - dist1 - dist2) % MOD
  path[node].each do |nextnode|
    next if done[nextnode]
    queue.push([nextnode,1,dist1])
    dist1 += 1
  end
end

puts(ans)