let m = 1000000007
let ( *^ ) x y = (x * y) mod m

let () = Scanf.scanf "%d %d\n" @@ fun n k ->
  let es = Array.make n [] in
  for i = 0 to n - 2 do
    Scanf.scanf "%d %d\n" @@ fun a b ->
      es.(a - 1) <- b - 1 :: es.(a - 1);
      es.(b - 1) <- a - 1 :: es.(b - 1)
  done;
  let visited = Array.make n false in
  let rec visit n v =
    if visited.(v)
    then None
    else begin
      visited.(v) <- true;
      let acc, _ = List.fold_left (fun (acc, n) u ->
        match visit n u with
        | None -> (acc, n)
        | Some x -> (acc *^ x, n - 1)) (1, if k <= n then k - 1 else k - 2) es.(v) in
      Some (max 0 n *^ acc)
    end in
  Printf.printf "%d\n" @@
  match visit k 0 with
  | None -> 0
  | Some x -> x
