mod=1000000007
n,k=gets.split.map(&:to_i)
l=[nil]
n.times do
  l << []
end
(n-1).times do
  a,b=gets.split.map(&:to_i)
  l[a] << b
  l[b] << a
end
v=[0]*(n+1)
v[1]=1
c=k
kk=k-1
s=[]
[1].each do |ss|
  l[ss].each do |lss|
    v[lss]=1
    s << lss
    c=c*kk%mod
    kk-=1
  end
end
while s!=[]
  z=[]
  s.each do |ss|
    kk=k-2
    l[ss].each do |lss|
      if v[lss]==0
        v[lss]=1
        z << lss
        c=c*kk%mod
        kk-=1
      end
    end
  end
  s=z.dup
end
puts c
