M = 1_000_000_007

def perm(n,k)
  return 0 if k < 0 || k > n

  o = 1
  k.times{|i| o = o*(n-i)%M}
  o % M
end

n, k = gets.split.map(&:to_i)
adjs = {}

(n-1).times.map do
  a, b = gets.split.map(&:to_i)
  (adjs[a] ||= []) << b
  (adjs[b] ||= []) << a
end

cnt = perm(k, adjs[1].size+1)

que = []
visited = {}
visited[1] = true
adjs[1].each do |u|
  que << u
end

while !que.empty?
  u = que.shift
  next if visited[u]
  visited[u] = true
  cnt = cnt * perm(k-2, adjs[u].size-1) % M
  adjs[u].each do |v|
    que << v if !visited[v]
  end
end

puts cnt
