(N, K), *ABs = readlines.map{|l| l.split.map(&:to_i)}
M = 10**9 + 7

@g = ABs.each_with_object(Hash.new{|h, k| h[k] = []}){|(a, b), o| o[a] << b; o[b] << a}
@g[1] << 0

def dfs(f, v, x = K - 2)
  s = @g[v].size
  return 0 if K < s
  y = x.downto(1).take(s - 1).inject(:*) || 1
  (@g[v] - [f]).inject(y){|r, t| r = r * dfs(v, t) % M}
end

puts K * dfs(0, 1, K - 1) % M