N, K = gets.chomp.split(" ").map(&:to_i)
sides = []
(N - 1).times do
  sides << gets.chomp.split(" ").map(&:to_i)
end
multiplier = []
multiplier << K
queue = []
queue.push(1)
tmp = 0
until queue.empty? do
  num = queue.shift
  selected = sides.select {|a, b| a == num || b == num}
  multi = K - 1
  (0...selected.length).each do |sele|
    multiplier << multi - sele - [tmp, 1].min
  end
  selected.each do |select|
    if select[0] == num
      queue.push(select[1])
    else
      queue.push(select[0])
    end
  end
  sides.delete_if {|a, b| a == num || b == num}
  tmp += 1
end
# p multiplier
puts multiplier.inject(:*) % 1000000007
# p sides