N,K=gets.split.map(&:to_i)
path=Array.new(N+1){Array.new}
option=Array.new(N+1,K)
checked=Array.new(N+1,false)
for i in 1..N-1
    a,b=gets.split.map &:to_i
    path[a] << b
    path[b] << a
end
stack=[1]
until stack.empty?
    pres=stack.shift
    next if checked[pres]
    checked[pres]=true
    visitable=path[pres]
    stack += visitable
    path[pres].each do |x|
        visitable += path[x]
    end
    minus=Array.new(N+1,false)
    visitable.each do |x|
        if !checked[x] && !minus[x]
            option[x]-=1
            minus[x]=true
        end
    end
end
ans=1
for i in 1..N
    ans*=option[i]
    ans%=10**9+7
end
puts ans
