module List = ListLabels

let ( *@) a b = (a * b ) mod 1000000007

let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let g =
    let g = Array.init (n+1) (fun _ -> []) in
    for i = 1 to n-1 do
      Scanf.scanf " %d %d" @@ fun a b ->
        g.(a) <- b :: g.(a);
        g.(b) <- a :: g.(b);
    done; g
  in

  let rec dfs x p c d2 =
    List.fold_left g.(x) ~init:(c, 0) ~f:(fun (a, j) y ->
      if y = p then (a, j) else
      let m = dfs y x (c-1-j+d2) (j + min 1 p) in
      (a *@ m, j+1))
    |> fst
  in
  dfs 1 0 k 0 |> Printf.printf "%d\n"
