let md = 1000000007;;
let ( *** ) x y = x * y mod md;;

let n, k = Scanf.scanf "%d %d" (fun x y -> x, y);;
let deg = Array.make n 0;;
for i = 1 to n - 1 do
  let a, b = Scanf.scanf " %d %d" (fun x y -> x-1, y-1) in
  deg.(a) <- deg.(a) + 1;
  deg.(b) <- deg.(b) + 1;
done;;

let rec perm n r = if n < 0 || r < 0 || n < r then 0
               else if r == 0 then 1
               else n *** perm (n - 1) (r - 1);;

Array.mapi (fun i x -> if i = 0 then perm k (x + 1) else perm (k-2) (x - 1)) deg
|> Array.fold_left ( *** ) 1
|> print_int;;
print_newline ();;
