#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = 1LL * x * p.x % mod; return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(ll n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};
const int mod = 1000000007;
using mint = ModInt<mod>;

template <typename T>
struct Combination {
    vector<T> _fac, _finv, _inv;

    Combination(int n) : _fac(n+1), _finv(n+1), _inv(n+1){
        _fac[0] = _finv[n] = _inv[0] = 1;
        for (int i = 1; i <= n; ++i) _fac[i] = _fac[i-1] * i;
        _finv[n] /= _fac[n];
        for (int i = n-1; i >= 0; --i) _finv[i] = _finv[i+1] * (i+1);
        for (int i = 1; i <= n; ++i) _inv[i] = _finv[i] * _fac[i-1];
    }
    inline T fac(int k) const { return _fac[k]; }
    inline T finv(int k) const { return _finv[k]; }
    inline T inv(int k) const { return _inv[k]; }

    T perm(int n, int k) const {
        return (k < 0 || n < k) ? 0 : fac(n) * finv(n-k);
    }
    T comb(int n, int k) const {
        return (k < 0 || n < k) ? 0 : fac(n) * finv(k) * finv(n-k);
    }
};
Combination<mint> C(100010);

int n, k;
vector<vector<int>> G;
mint res;

void dfs(int v, int p) {
    if (p == -1) {
        res *= C.perm(k-1, G[v].size());
    } else {
        res *= C.perm(k-2, G[v].size() - 1);
    }
    for (auto nv : G[v]) {
        if (nv == p) continue;
        dfs(nv, v);
    }
}

int main(){
    cin >> n >> k;
    G.resize(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    res = k;
    dfs(0, -1);
    cout << res << endl;
}

Measured memory_bytes: 14516