N, K = gets.split.map(&:to_i)
tree = Hash.new{|hash, key| hash[key] = []}
(N-1).times do |i|
  a,b = gets.split.map(&:to_i)
  tree[a] << b
  tree[b] << a
end

def fact(n)
  (1..n).to_a.inject(1) {|f, i| f*i}
end

def perm(n,k)
  return 1 if k > n || k == 0
  fact(n)/fact(n-k)
end
mod = 10**9 + 7
ans = K
if N == 1
  puts K
else
  visited = Array.new(N+1,false)
  q = [1]
  flag = 1

  while q != []
    tmp = []
    q.each{|x|
      visited[x] = true
      childs = tree[x].select{|t| visited[t] == false}
      ans = (ans * perm(K - flag, childs.size)) % mod
      tmp = tmp + childs
    }
    q = tmp
    flag = 2
end
puts ans
end