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

mod = 10 ** 9 + 7

ans = (edge[1].size + 1).times.inject(1) {|r, i| r * (k - i) % mod}
que = edge[1].product([1])

while now = que.shift
    x, y = now
    ans = ans * (edge[x].size - 1).times.inject(1) {|r, i| r * (k - i - 2) % mod} % mod
    que += (edge[x] - [y]).product([x])
end

puts ans