/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 1000000000
#define PI 3.1415926
#define coutdb cout << fixed << setprecision(10)

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int V, K;
vector<int> graph[100000];
typedef pair<int, int> P;

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> V >> K;
  int a, b;
  REP(i, V-1){
    cin >> a >> b; a--; b--;
    graph[a].pb(b);
    graph[b].pb(a);
  }
  int mx = -1, mxidx = 0;
  REP(i, V){
    if(mx < graph[i].size()){
      mx = graph[i].size(); mxidx = i;
    }
  }
  int ans = K;
  int d[100000];
  fill(d, d+V, INF); d[mxidx] = 0;
  queue<int> que; que.push(mxidx);
  while(!que.empty()){
    int pos = que.front(); que.pop();
    if(d[pos] == 0){
      for(int i = 1; i <= graph[pos].size(); i++){
        if(K-i < 0){
          cout << 0 << endl;
          return 0;
        }
        ans *= (K-i); ans %= MOD;
      }
    } else {
      for(int i = 2; i <= graph[pos].size(); i++){
        if(K-i < 0){
          cout << 0 << endl;
          return 0;
        }
        ans *= (K-i); ans %= MOD;
      }
    }
    REP(i, graph[pos].size()){
      int next = graph[pos][i];
      if(d[next] == INF){
        d[next] = d[pos] + 1;
        que.push(next);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 8180