//
//  main.cpp
//  test
//
//  Created by wu bowen on 2019/04/25.
//  Copyright © 2019 wu bowen. All rights reserved.
//

#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
const ll mod = 1e9 + 7;
ll mmod = 1e9 + 7;

template <long long mod>
struct mint {
    long long v;
    mint(long long x = 0) : v(x >= 0 ? x % mod : mod >= -x ? mod + x : -(-x % mod) + mod) {}
    mint &operator+=(const mint &r)
    {
        if ((v += r.v) >= mod)
        {
            v -= mod;
        }
        return *this;
    }
    mint &operator-=(const mint &r)
    {
        if ((v -= r.v) < 0)
        {
            v += mod;
        }
        return *this;
    }
    mint &operator*=(const mint &r)
    {
        if ((v *= r.v) >= mod)
        {
            v %= mod;
        }
        return *this;
    }
    mint &operator/=(const mint &r)
    {
        *this *= r.inverse();
        return *this;
    }
    mint &operator+(const mint &r)
    {
        *this += r;
        return *this;
    }
    mint &operator-(const mint &r)
    {
        *this -= r;
        return *this;
    }
    mint &operator*(const mint &r)
    {
        *this *= r;
        return *this;
    }
    mint &operator/(const mint &r)
    {
        *this /= r;
        return *this;
    }
    mint &operator-()
    {
        return mint(-v);
    }
    mint pow(long long n)
    {
        mint constant = mint(v);
        mint tmp = mint(1);
        
        while (n > 0)
        {
            if (n & 1)
            {
                tmp *= constant;
            }
            
            constant *= constant;
            n >>= 1;
        }
        return tmp;
    }
    mint inverse()
    {
        long long mi = mod - 2ll;
        return pow(mi);
    }
    
};

typedef mint<mod> mmint;
vector<vector<int>> g;
vector<bool> check;
int root;

vector<ll> fac;
vector<ll> inv;

long long ppow(const long long &v, const long long &n, const long long &mod)
{
    long long ret = 1;
    long long num = n;
    long long now = v;
    
    while (num > 0)
    {
        if (num & 1)
        {
            ret = ret * now % mod;
        }
        now = (now * now) % mod;
        num = num >> 1;
    }
    
    return ret;
}

long long calc(const long long &n, const long long &k, const long long &mod)
{
    long long ret;
    
    ret = fac[n] * inv[n - k] % mod;
    
    return ret;
}

int froot(int v)
{
    if (check[v])
    {
        return -1;
    }
    check[v] = 1;
    for (int i = 0; i < g[v].size(); ++i)
    {
        int ret = froot(g[v][i]);
        if (ret != -1)
        {
            return ret;
        }
    }
    return v;
}

mmint dfs(int v, int k)
{
    if (check[v])
    {
        return 1;
    }
    check[v] = 1;
    mmint ret = 1;
    
    if (g[v].size() > k - 1)
    {
        return 0;
    }

    if (v == root)
    {
        ret *= calc(k - 1, g[v].size(), mod);
    }
    else
    {
        ret *= calc(k - 2, g[v].size() - 1, mod);
    }
    
    for (int i = 0; i < g[v].size(); ++i)
    {
        ret *= dfs(g[v][i], k);
    }
    return ret;
}

int main() {

    
    int n, k;
    cin >> n >> k;
    
    g = vector<vector<int>>(n, vector<int>());
    check = vector<bool>(n, 0);
    
    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);
    }
    
    root = froot(0);
    check = vector<bool>(n, 0);
    fac = vector<long long>(k + 1, 1);
    inv = vector<long long>(k + 1, 1);
    for (int i = 1; i <= k; ++i)
    {
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = ppow(fac[i], mmod - 2, mod);
    }
    
    mmint ret = dfs(root, k) * k;
    
    cout << ret.v << endl;

    return 0;
}



Measured memory_bytes: 10368