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

//const int mod = 1000000007;
//const int mod = 998244353;
template <typename T, T MOD = 1000000007>
struct Mint {
    static constexpr T mod = MOD;
    T v;
    Mint() : v(0) {}
    Mint(signed v) : v(v) {}
    Mint(long long t) {
        v = t % MOD;
        if (v < 0) v += MOD;
    }

    Mint pow(long long k) {
        Mint res(1), tmp(v);
        while (k) {
            if (k & 1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }

    static Mint add_identity() { return Mint(0); }
    static Mint mul_identity() { return Mint(1); }

    Mint inv() { return pow(MOD - 2); }

    Mint& operator+=(Mint a) {
        v += a.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    Mint& operator-=(Mint a) {
        v += MOD - a.v;
        if (v >= MOD) v -= MOD;
        return *this;
    }
    Mint& operator*=(Mint a) {
        v = 1LL * v * a.v % MOD;
        return *this;
    }
    Mint& operator/=(Mint a) { return (*this) *= a.inv(); }

    Mint operator+(Mint a) const { return Mint(v) += a; }
    Mint operator-(Mint a) const { return Mint(v) -= a; }
    Mint operator*(Mint a) const { return Mint(v) *= a; }
    Mint operator/(Mint a) const { return Mint(v) /= a; }

    Mint operator-() const { return v ? Mint(MOD - v) : Mint(v); }

    bool operator==(const Mint a) const { return v == a.v; }
    bool operator!=(const Mint a) const { return v != a.v; }
    bool operator<(const Mint a) const { return v < a.v; }

    static Mint comb(long long n, int k) {
        Mint num(1), dom(1);
        for (int i = 0; i < k; i++) {
            num *= Mint(n - i);
            dom *= Mint(i + 1);
        }
        return num / dom;
    }
};
template <typename T, T MOD>
constexpr T Mint<T, MOD>::mod;
template <typename T, T MOD>
ostream& operator<<(ostream& os, Mint<T, MOD> m) {
    os << m.v;
    return os;
}
template <typename T, T MOD>
istream& operator>>(istream& os, Mint<T, MOD>& m) {
    os >> m.v;
    return os;
}

// https://github.com/atcoder-live/library/blob/master/comb.cpp
// https://github.com/atcoder-live/library/blob/master/comb.cpp
template <typename T, T MOD = 1000000007>
struct combination {
    vector<Mint<T, MOD>> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) {
            fact[i] = fact[i - 1] * i;
        }
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) {
            ifact[i - 1] = ifact[i] * i;
        }
    }
    Mint<T, MOD> operator()(int n, int k) {
        if (k < 0 || k > n) return Mint<T, MOD>(0);
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

typedef Mint<long long> P;

int main() {
    int N, K;
    cin >> N >> K;
    vector<vector<int>> G(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);
    }
    // 頂点番号0を根とする。
    vector<int> visited(N, false);
    stack<int> stk;
    P res(K);
    combination<long long> Cmb(K);
    res *= Cmb(K - 1, G[0].size()) * Cmb.fact[G[0].size()];
    for (int t : G[0]) stk.push(t);
    visited[0] = true;
    while (!stk.empty()) {
        int f = stk.top();
        stk.pop();
        if (visited[f]) continue;
        visited[f] = true;
        res *= Cmb(K - 2, G[f].size() - 1) * Cmb.fact[G[f].size() - 1];
        for (int t : G[f]) {
            if (!visited[t]) stk.push(t);
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8440