#include <bits/stdc++.h>

using namespace std;
using ll = long long;

ll mod = 1000000007;

template<unsigned int mod_>
struct ModInt {
  using uint = unsigned int;
  using ll = long long;
  using ull = unsigned long long;

  constexpr static uint mod = mod_;

  uint v;

  ModInt() : v(0) {}

  ModInt(ll _v) : v(normS(_v % mod + mod)) {}

  explicit operator bool() const { return v != 0; }

  static uint normS(const uint &x) { return (x < mod) ? x : x - mod; }    // [0 , 2*mod-1] -> [0 , mod-1]
  static ModInt make(const uint &x) {
    ModInt m;
    m.v = x;
    return m;
  }

  ModInt operator+(const ModInt &b) const { return make(normS(v + b.v)); }

  ModInt operator-(const ModInt &b) const { return make(normS(v + mod - b.v)); }

  ModInt operator-() const { return make(normS(mod - v)); }

  ModInt operator*(const ModInt &b) const { return make((ull) v * b.v % mod); }

  ModInt operator/(const ModInt &b) const { return *this * b.inv(); }

  ModInt &operator+=(const ModInt &b) { return *this = *this + b; }

  ModInt &operator-=(const ModInt &b) { return *this = *this - b; }

  ModInt &operator*=(const ModInt &b) { return *this = *this * b; }

  ModInt &operator/=(const ModInt &b) { return *this = *this / b; }

  ModInt &operator++(int) { return *this = *this + 1; }

  ModInt &operator--(int) { return *this = *this - 1; }

  ll extgcd(ll a, ll b, ll &x, ll &y) const {
    ll p[] = {a, 1, 0}, q[] = {b, 0, 1};
    while (*q) {
      ll t = *p / *q;
      for (int i = 0; i < 3; ++i) {
        swap(p[i] -= t * q[i], q[i]);
      }
    }
    if (p[0] < 0) {
      for (int i = 0; i < 3; ++i) {
        p[i] = -p[i];
      }
    }
    x = p[1], y = p[2];
    return p[0];
  }

  ModInt inv() const {
    ll x, y;
    extgcd(v, mod, x, y);
    return make(normS(x + mod));
  }

  ModInt pow(ll p) const {
    if (p < 0) return inv().pow(-p);
    ModInt a = 1;
    ModInt x = *this;
    while (p) {
      if (p & 1) a *= x;
      x *= x;
      p >>= 1;
    }
    return a;
  }

  bool operator==(const ModInt &b) const { return v == b.v; }

  bool operator!=(const ModInt &b) const { return v != b.v; }

  friend istream &operator>>(istream &o, ModInt &x) {
    ll tmp;
    o >> tmp;
    x = ModInt(tmp);
    return o;
  }

  friend ostream &operator<<(ostream &o, const ModInt &x) { return o << x.v; }
};

using mint = ModInt<1000000007>;

// 階乗、階乗の逆元、逆元
const int MAX = 100011;
mint fact[MAX], finv[MAX], inv[MAX];

// 階乗、逆元の前処理
void Cinit() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fact[i] = fact[i - 1] * i;
    inv[i] = -(inv[mod % i] * (mod / i));
    finv[i] = finv[i - 1] * inv[i];
  }
}

mint nPk(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fact[n] * finv[n - k];
}

vector<ll> link[100011];

ll N, K;
mint dfs(ll now, ll parent) {
  if(K<link[now].size())
    return 0;
  int k = K-2;
  int child_num = link[now].size() - 1;
  if(parent == 999999) {
    k = K - 1;
    child_num++;
  }

  mint ret = nPk(k, child_num);

  for (auto l : link[now]) {
    if(l == parent)
      continue;
    ret *= dfs(l, now);
  }
  return ret;
}

int main() {
  Cinit();

  cin >> N >> K;

  for (int i = 0; i < N-1; ++i) {
    ll a, b;
    cin >> a >> b;
    link[a-1].push_back(b-1);
    link[b-1].push_back(a-1);
  }

  cout << dfs(0, 999999)*K << endl;
}




Measured memory_bytes: 11520