#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <map>

constexpr intmax_t mod = 1e9+7;

template <typename Weight>
struct edge {
  using value_type = Weight;
  size_t src, dst;
  value_type cost;

  edge(size_t src, size_t dst, value_type cost = 1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(edge<value_type> const& rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <typename Weight>
struct graph: public std::vector<std::vector<edge<Weight>>> {
  using value_type = Weight;
  graph(size_t n): std::vector<std::vector<edge<value_type>>>(n) {}

  void connect_to(size_t src, size_t dst, value_type cost = 1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  void connect_with(size_t src, size_t dst, value_type cost = 1) {
    connect_to(src, dst, cost);
    connect_to(dst, src, cost);
  }
};

template <typename Tp>
Tp gcd(Tp a, Tp b, Tp& x, Tp& y) {
  x = Tp(0);
  y = Tp(1);
  for (Tp u = y, v = x; a;) {
    Tp q = b/a;
    std::swap(x -= q*u, u);
    std::swap(y -= q*v, v);
    std::swap(b -= q*a, a);
  }
  return b;
}

template <typename Tp>
Tp modinv(Tp a, Tp mod) {
  Tp x, y;
  gcd(a, mod, x, y);
  x %= mod;
  if (x < 0) x += mod;
  return x;
}

template <typename Tp>
Tp modadd(Tp a, Tp b, Tp mod) {
  a += b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <typename Tp>
Tp modadd(std::initializer_list<Tp> const& adds, Tp mod) {
  Tp res = 0;
  for (auto const& add: adds) {
    res += add % mod;
    if (res < 0) res += mod;
    if (res >= mod) res -= mod;
  }
  return res;
}

template <typename Tp>
Tp modsub(Tp a, Tp b, Tp mod) {
  a -= b % mod;
  if (a < 0) a += mod;
  if (a >= mod) a -= mod;
  return a;
}

template <class Tp>
Tp modmul(std::initializer_list<Tp> const& muls, Tp mod) {
  Tp res = 1;
  for (auto const& mul: muls) (res *= mul) %= mod;
  return res;
}

template <typename Tp>
Tp modpow(Tp base, intmax_t iexp, Tp mod) {
  Tp res = 1;
  for (Tp dbl = base; iexp; iexp >>= 1) {
    if (iexp & 1) res = res * dbl % mod;
    dbl = dbl * dbl % mod;
  }
  return res;
}

class modfactorial {
  std::vector<intmax_t> fact, fact_inv;
  intmax_t mod;

public:
  modfactorial(intmax_t N, intmax_t mod): mod(mod) {
    fact.resize(N+1);
    fact_inv.resize(N+1);
    fact[0] = 1;
    for (intmax_t i = 1; i <= N; ++i)
      fact[i] = fact[i-1] * i % mod;

    fact_inv[N] = modinv(fact[N], mod);
    for (intmax_t i = N; i--;)
      fact_inv[i] = fact_inv[i+1] * (i+1) % mod;
  }

  intmax_t operator ()(intmax_t k) const {
    return fact[k];
  }

  intmax_t inverse(intmax_t k) const {
    return fact_inv[k];
  }
};

template <typename F>
class fix_point: F {
public:
  explicit constexpr fix_point(F&& f) noexcept: F(std::forward<F>(f)) {}

  template <typename... Args>
  constexpr decltype(auto) operator ()(Args&&... args) const {
    return F::operator ()(*this, std::forward<Args>(args)...);
  }
};

template <typename F>
static inline constexpr decltype(auto) make_fix_point(F&& f) noexcept {
  return fix_point<F>{std::forward<F>(f)};
}

using tree = graph<int>;
intmax_t pomae(tree const& g, size_t k) {
  size_t n = g.size();
  modfactorial mf(std::max(n, k)+2, mod);
  intmax_t k1 = mf(k-1);

  std::vector<intmax_t> dp0(n), dp1(n);
  std::vector<size_t> child(n);
  (make_fix_point([&](auto dfs, size_t v, size_t p) -> void {
    (void)0;
    // fprintf(stderr, "v: %zu\n", v);
    dp0[v] = dp1[v] = 1;
    size_t deg = 0;
    for (auto const& e: g[v]) {
      ++deg;
      if (e.dst == p) continue;
      ++child[v];
      dfs(e.dst, e.src);
      (dp0[e.src] *= dp1[e.dst]) %= mod;
    }
    size_t c = child[v];
    if (k >= 2+c) {
      (dp1[v] = dp0[v] * mf(k-2) % mod * mf.inverse(k-2-c) % mod);
    } else {
      dp1[v] = 0;
    }
    if (k >= 1+c) {
      (dp0[v] *= mf(k-1) * mf.inverse((k-1)-c) % mod) %= mod;
    } else {
      dp0[v] = 0;
    }
  }))(0, -1);

  // for (size_t i = 0; i < n; ++i)
  //   fprintf(stderr, "%zu: %jd (%zu)\n", i+1, dp0[i], child[i]);

  return (dp0[0] * k) % mod;
}

int main() {
  size_t N, K;
  scanf("%zu %zu", &N, &K);

  tree g(N);
  for (size_t i = 1; i < N; ++i) {
    size_t a, b;
    scanf("%zu %zu", &a, &b);
    --a;
    --b;
    g.connect_with(a, b);
  }

  // for (size_t i = 0; i < N; ++i)
  //   if (g[i].size() >= K) return puts("0"), 0;

  printf("%jd\n", pomae(g, K));
}


Measured memory_bytes: 19200