local n,k=io.read("n","n")
local edge={}

for i=1,n do
    edge[i]={}
end
for i=1,n-1 do
    local a,b=io.read("n","n")
    table.insert(edge[a],b)
    table.insert(edge[b],a)
end

local mod=1000000007
local pattern=1
local function dfs(me,parent,x)
    pattern=pattern*x%mod
    x=k-1
    if parent>0 then
        x=x-1
    end
    for _,v in pairs(edge[me]) do
        if v~=parent then
            dfs(v,me,x)
            x=x-1
        end
    end
end

dfs(1,0,k)
print(pattern)