lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
K = lines[0][1]
Mod = 10 ** 9 + 7

access = []
for i in 1..N do
  access[i-1] = []
end
for i in 1..N-1 do
  from = lines[i][0]
  to = lines[i][1]
  access[from-1].push(to)
  access[to-1].push(from)
end

adj_col = []
visited = []
for i in 1..N do
  adj_col[i-1] = 0
  visited[i-1] = false
end

ans = 1
target = [1]
impossible = false
while target != [] do
  i = target.pop
  visited[i-1] = true
  adj2_col = 0
  access[i-1].each do |j|
    adj2_col += adj_col[j-1]
    adj_col[j-1] += 1
    if visited[j-1] == false then
      target.push(j)
    end
  end
  if adj_col[i-1] + adj2_col >= K then
    impossible = true
    break
  else
    ans = (ans * (K - adj_col[i-1] - adj2_col)) % Mod
  end
end
    
if impossible then
  puts 0
else
  puts ans
end