#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

const LL MOD = 1000000007;
VL fact_memo(100005+1);

LL mod_pow_fast(LL a,LL n){
    LL p = a;
    LL ret = 1;
    while(n){
        if(n & 1) ret = (ret * p) % MOD;
        n = n >> 1;
        p = (p * p) % MOD;
    }
    return ret;
}
LL mod_inv(LL x){
    return mod_pow_fast(x, MOD - 2);
}
LL mod_fact(LL n){
    if(n <= 100005)return fact_memo[n];

    LL ret = 1;
    for(LL i = 2; i <= n; i++){
        ret = (ret * i) % MOD;
    }
    return ret;
}
LL mod_comb(LL n, LL r){
    // nCr = n! * inv(r!) * inv((n-r)!)
    return (((mod_fact(n) * mod_inv(mod_fact(r))) % MOD) *
                            mod_inv(mod_fact(n-r))) % MOD;
}

class ModCombination{
    vector<LL> fact_, inv_, finv_;
public:
    ModCombination() {}
    ModCombination(LL n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) {
        init(n);
    }
    void init(LL n) noexcept {
        fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1);
        for(LL i = 2; i < n; i++){
            fact_[i] = fact_[i-1] * i % MOD;
            inv_[i] = MOD - inv_[MOD%i] * (MOD/i) % MOD;
            finv_[i] = finv_[i-1] * inv_[i] % MOD;
        }
    }
    LL comb(LL n, LL k) const noexcept {
        if (n < k || n < 0 || k < 0) return 0;
        return fact_[n] * (finv_[k] * finv_[n-k] %MOD) % MOD;
    }
    LL fact(LL n) const noexcept {
        if (n < 0) return 0;
        return fact_[n];
    }
    LL inv(LL n) const noexcept {
        if (n < 0) return 0;
        return inv_[n];
    }
    LL finv(LL n) const noexcept {
        if (n < 0) return 0;
        return finv_[n];
    }
};
ModCombination mc(100005);

vector<VL> link(100005);

LL n,k;
LL ans = 0;

void f(LL node, LL depth, LL parent){
    LL sz = link[node].size();
    //if(sz <= 1)return;
    //if(k - 2 < sz - 1){
    //    ans = 0;
    //    return;
    //}
    //LL x = (mod_comb(k - 2, sz-1) * mod_fact(sz-1)) % MOD;
    //LL x = (mc.comb(k - 2, sz-1) * mc.fact(sz-1)) % MOD;
    LL x = parent == -1 ?
        (mc.comb(k - 1, sz) * mc.fact(sz)) % MOD :
        (mc.comb(k - 2, sz-1) * mc.fact(sz-1)) % MOD ;
    ans = (ans * x) % MOD;
    REP(i,sz)if(link[node][i] != parent){
        f(link[node][i], depth+1, node);
    }
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n>>k;
    REP(i,n-1){
        LL a,b;
        cin>>a>>b;
        link[a].PB(b);
        link[b].PB(a);
    }
    //fact_memo[0] = 1;
    //FOR(i,1,100005+1){
    //    fact_memo[i] = (i * fact_memo[i-1]) % MOD;
    //}
    ans = k;
    //LL sz = link[1].size();
    //if(k - 1 < sz){
    //    ans = 0;
    //}
    //LL x = (mod_comb(k - 1, sz) * mod_fact(sz)) % MOD;
    //LL x = (mc.comb(k - 1, sz) * mc.fact(sz)) % MOD;
    //ans = (ans * x) % MOD;
    //REP(i,sz){
    //    f(link[1][i], 2, 1);
    //}
    f(1, 1, -1);
    PUTS(ans);
}

Measured memory_bytes: 13568