#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
inline ll LCM(ll a, ll b){return a / GCD(a, b) * b;}
inline ll powint(ll x, ll y){ll r=1;while(y){if(y&1)r*=x;x*=x;y>>=1;}return r;}
inline ll powmod(ll x, ll y, ll m = MOD){ll r=1;while(y){if(y&1)r*=x;x*=x;r%=m;x%=m;y>>=1;}return r;}
/* END OF TEMPLATE */


// https://github.com/beet-aizu/library/blob/master/M/mint.cpp
template<typename T,T Mod = MOD>
struct Mint{
    static constexpr T M = Mod;
    T v;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%M;if(v<0) v+=M;}

    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(M-2);}

    Mint& operator+=(Mint a){v+=a.v;if(v>=M)v-=M;return *this;}
    Mint& operator-=(Mint a){v+=M-a.v;if(v>=M)v-=M;return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%M;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(M-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;}

    // find x s.t. a^x = b
    static T log(T a,T b){
        const T sq=40000;
        unordered_map<T, T> dp;
        dp.reserve(sq);
        Mint res(1);
        for(int r=0;r<sq;r++){
        if(!dp.count(res.v)) dp[res.v]=r;
        res*=a;
        }
        Mint p=Mint(a).inv().pow(sq);
        res=b;
        for(int q=0;q<=M/sq+1;q++){
        if(dp.count(res.v)){
            T idx=q*sq+dp[res.v];
            if(idx>0) return idx;
        }
        res*=p;
        }
        assert(0);
        return T(-1);
    }
    
    // nCk
    static Mint comb(long long n,int k){
        Mint num(1),dom(1);
        rep(i, k){
            num*=Mint(n-i);
            dom*=Mint(i+1);
        }
        return num/dom;
    }
};
template<typename T,T M> constexpr T Mint<T, M>::M;
template<typename T,T M>
ostream& operator<<(ostream &os,Mint<T, M> m){os<<m.v;return os;}
//------------------------------------------------------------

ll k;
// 隣接リスト
vvll g(100010, vll());
vll vcol(100010, 0);
vi visited(100010, 0);

// グラフに対する幅優先探索
void bfs(ll start){
    queue<pair<ll, pll>> q;
    visited[start] = 1;
    ll depth = 0;
    ll parent = start;
    ll col = k;
    q.push(make_pair(start, make_pair(depth, parent)));
    while (!q.empty()) {
        depth = q.front().second.first;
        if(depth == 0){
            col = k;
        }else if(parent == q.front().second.second){
            col = max(col-1, 0ll);
        }else{
            col = k-min(2ll, depth);
        }
        //dump(col);
        //dump(depth);
        ll now = q.front().first;
        parent = q.front().second.second;
        vcol[now] = col;
        q.pop();
        rep(i, SZ(g[now])){
            ll next = g[now][i];
            if(!visited[next]){
                visited[next] = 1;
                q.push(make_pair(next, make_pair(depth+1, now)));
            }
        }
    }
}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n >> k;
    vll a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        g[a[i]-1].emplace_back(b[i]-1);
        g[b[i]-1].emplace_back(a[i]-1);
    }
    bfs(0);
    ll ans = 1;
    rep(i, n){
        ans *= vcol[i];
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11636