module queue
  implicit none
  type :: JagArray
    integer,allocatable :: array(:)
  end type JagArray
  contains
  subroutine push(A,b)
    integer,allocatable,dimension(:)::A
    integer::b
    A=[A,b]
  end subroutine
  subroutine pop(A)
    integer,allocatable,dimension(:)::A
    A=A(2:)
  end subroutine
end module queue

module Factwithmod
  implicit none
  integer(8),allocatable,dimension(:)::Kaijo
  contains
subroutine initiationFactorial(maxnum,mo)
  implicit none
  integer(8)::maxnum
  integer(8)::mo
  integer(8)::i

  allocate(Kaijo(0:maxnum))
  Kaijo(0)=1
  do i=1,maxnum
    Kaijo(i)=mod(Kaijo(i-1)*i,mo)
  end do
end subroutine

function combination(n,k,l)
implicit none
integer(8),intent(in)::n,k,l
integer(8)::combination

combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function combination

function inv(K,L)
integer(8),intent(in)::k,l
integer(8) l2,y
integer(8) inv
inv=1
l2=l-2
y=k
do
  if(mod(l2,2)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=l2/2
  if(l2==0)exit
end do
end function inv

function permutation(n,k,mo)
implicit none
  integer(8)::n,k
  integer(8)::mo
  integer(8)::permutation
  permutation=mod(Kaijo(N)*inv(Kaijo(N-K),mo),mo)
end function permutation
end module Factwithmod

use queue
use Factwithmod
integer(8) N,K
integer A,B
type(JagArray),allocatable,dimension(:)::EDGE
integer(8) ans
integer(8) mo
integer(8) i,child
read*,N,K
allocate(EDGE(N))
mo=10**9+7
do i=1,N
  EDGE(i)%array=[integer::]
end do
do i=1,N-1
  read*,A,B
  call push(EDGE(A)%array,B)
  call push(EDGE(B)%array,A)
end do

call initiationFactorial(max(n,K),mo)
child=size(EDGE(1)%array)
ans=permutation(K-1,child,mo)*K
do i=2,N
  child=size(EDGE(i)%array)-1
  ans=mod(ans*permutation(K-2,child,mo),mo)
end do

print"(i0)",ans
end