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

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

p ans