N,K = gets.split.map &:to_i
es = (0..N).map{ {} }
(N-1).times{
  a,b = gets.split.map &:to_i
  es[a][b] = es[b][a] = 1
}

ans = K
Mod = 10**9+7
queue = [0, es[1].keys.map{ |n| [1,n] }].flatten
Visited = Array.new(N+1,false)
VisitedCount = Array.new(N+1, 0)
Visited[1] = true
while queue.size > 0 do
  n = queue.pop
  break if n == 0
  VisitedCount[n] += 1
  next if Visited[n]
  Visited[n] = true
  ans = (ans * [K-VisitedCount[queue[-1]]-1, 0].max) % Mod
  es[n].keys.each{ |m|
    next if Visited[m]
    queue << n; queue << m
  }
end

p ans