#include<bits/stdc++.h>
using namespace std;
#define MD 1000000007
void *wmem;
struct mint{
  static unsigned R, RR, Rinv, W, md, mdninv;
  unsigned val;
  mint(){
  }
  mint(int a){
    val = mulR(a);
  }
  mint(unsigned a){
    val = mulR(a);
  }
  mint(long long a){
    val = mulR(a);
  }
  mint(unsigned long long a){
    val = mulR(a);
  }
  int get_inv(long long a, int md){
    long long e, s=md, t=a, u=1, v=0;
    while(s){
      e=t/s;
      t-=e*s;
      u-=e*v;
      swap(t,s);
      swap(u,v);
    }
    if(u<0){
      u+=md;
    }
    return u;
  }
  void setmod(unsigned m){
    int i;
    unsigned t;
    W = 32;
    md = m;
    R = (1ULL << W) % md;
    RR = (unsigned long long)R*R % md;
    switch(m){
      case 104857601:
      Rinv = 2560000;
      mdninv = 104857599;
      break;
      case 998244353:
      Rinv = 232013824;
      mdninv = 998244351;
      break;
      case 1000000007:
      Rinv = 518424770;
      mdninv = 2226617417U;
      break;
      case 1000000009:
      Rinv = 171601999;
      mdninv = 737024967;
      break;
      case 1004535809:
      Rinv = 234947584;
      mdninv = 1004535807;
      break;
      case 1007681537:
      Rinv = 236421376;
      mdninv = 1007681535;
      break;
      case 1012924417:
      Rinv = 238887936;
      mdninv = 1012924415;
      break;
      case 1045430273:
      Rinv = 254466304;
      mdninv = 1045430271;
      break;
      case 1051721729:
      Rinv = 257538304;
      mdninv = 1051721727;
      break;
      default:
      Rinv = get_inv(R, md);
      mdninv = 0;
      t = 0;
      for(i=0;i<(int)W;i++){
        if(t%2==0){
          t+=md;
          mdninv |= (1U<<i);
        }
        t /= 2;
      }
    }
  }
  unsigned mulR(unsigned a){
    return (unsigned long long)a*R%md;
  }
  unsigned mulR(int a){
    if(a < 0){
      a = a%md+md;
    }
    return mulR((unsigned)a);
  }
  unsigned mulR(unsigned long long a){
    return mulR((unsigned)(a%md));
  }
  unsigned mulR(long long a){
    a %= md;
    if(a < 0){
      a += md;
    }
    return mulR((unsigned)a);
  }
  unsigned reduce(unsigned T){
    unsigned m=T * mdninv, t=(unsigned)((T + (unsigned long long)m*md) >> W);
    if(t >= md){
      t -= md;
    }
    return t;
  }
  unsigned reduce(unsigned long long T){
    unsigned m=(unsigned)T * mdninv, t=(unsigned)((T + (unsigned long long)m*md) >> W);
    if(t >= md){
      t -= md;
    }
    return t;
  }
  unsigned get(){
    return reduce(val);
  }
  mint &operator+=(mint a){
    val += a.val;
    if(val >= md){
      val -= md;
    }
    return *this;
  }
  mint &operator-=(mint a){
    if(val < a.val){
      val = val + md - a.val;
    }
    else{
      val -= a.val;
    }
    return *this;
  }
  mint &operator*=(mint a){
    val = reduce((unsigned long long)val*a.val);
    return *this;
  }
  mint &operator/=(mint a){
    return *this *= a.inverse();
  }
  mint operator+(mint a){
    return mint(*this)+=a;
  }
  mint operator-(mint a){
    return mint(*this)-=a;
  }
  mint operator*(mint a){
    return mint(*this)*=a;
  }
  mint operator/(mint a){
    return mint(*this)/=a;
  }
  mint operator+(int a){
    return mint(*this)+=mint(a);
  }
  mint operator-(int a){
    return mint(*this)-=mint(a);
  }
  mint operator*(int a){
    return mint(*this)*=mint(a);
  }
  mint operator/(int a){
    return mint(*this)/=mint(a);
  }
  mint operator+(long long a){
    return mint(*this)+=mint(a);
  }
  mint operator-(long long a){
    return mint(*this)-=mint(a);
  }
  mint operator*(long long a){
    return mint(*this)*=mint(a);
  }
  mint operator/(long long a){
    return mint(*this)/=mint(a);
  }
  mint operator-(void){
    mint res;
    if(val){
      res.val=md-val;
    }
    else{
      res.val=0;
    }
    return res;
  }
  operator bool(void){
    return val!=0;
  }
  operator int(void){
    return get();
  }
  operator long long(void){
    return get();
  }
  mint inverse(){
    int a=val, b=md, t, u=1, v=0;
    mint res;
    while(b){
      t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    if(u < 0){
      u += md;
    }
    res.val = (unsigned long long)u*RR % md;
    return res;
  }
  mint pw(unsigned long long b){
    mint a(*this), res;
    res.val = R;
    while(b){
      if(b&1){
        res *= a;
      }
      b >>= 1;
      a *= a;
    }
    return res;
  }
  bool operator==(int a){
    return mulR(a)==val;
  }
  bool operator!=(int a){
    return mulR(a)!=val;
  }
}
;
mint operator+(int a, mint b){
  return mint(a)+=b;
}
mint operator-(int a, mint b){
  return mint(a)-=b;
}
mint operator*(int a, mint b){
  return mint(a)*=b;
}
mint operator/(int a, mint b){
  return mint(a)/=b;
}
mint operator+(long long a, mint b){
  return mint(a)+=b;
}
mint operator-(long long a, mint b){
  return mint(a)-=b;
}
mint operator*(long long a, mint b){
  return mint(a)*=b;
}
mint operator/(long long a, mint b){
  return mint(a)/=b;
}
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(mint x){
  int i;
  i = (int)x;
  wt_L(i);
}
struct graph{
  int N, **edge, *es;
  void setEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    es = (int*)(*mem);
    edge = (int**)(es+N);
    edge[0] = (int*)(edge+N);
    for(i=0;i<N;i++){
      es[i] = 0;
    }
    for(i=0;i<M;i++){
      es[A[i]]++;
      es[B[i]]++;
    }
    for(i=1;i<N;i++){
      edge[i] = edge[i-1] + es[i-1];
    }
    (*mem) = edge[N-1] + es[N-1];
    for(i=0;i<N;i++){
      es[i] = 0;
    }
    for(i=0;i<M;i++){
      edge[A[i]][es[A[i]]++] = B[i];
      edge[B[i]][es[B[i]]++] = A[i];
    }
  }
  void setDirectEdge(int N__, int M, int A[], int B[], void **mem = &wmem){
    int i;
    N = N__;
    es = (int*)(*mem);
    edge = (int**)(es+N);
    edge[0] = (int*)(edge+N);
    for(i=0;i<N;i++){
      es[i] = 0;
    }
    for(i=0;i<M;i++){
      es[A[i]]++;
    }
    for(i=1;i<N;i++){
      edge[i] = edge[i-1] + es[i-1];
    }
    (*mem) = edge[N-1] + es[N-1];
    for(i=0;i<N;i++){
      es[i] = 0;
    }
    for(i=0;i<M;i++){
      edge[A[i]][es[A[i]]++] = B[i];
    }
  }
  graph reverse(void **mem = &wmem){
    graph g;
    int i, j, k;
    g.N = N;
    g.es = (int*)(*mem);
    g.edge = (int**)(g.es + N);
    g.edge[0] = (int*)(g.edge + N);
    for(i=0;i<N;i++){
      g.es[i] = 0;
    }
    for(i=0;i<N;i++){
      for(j=0;j<es[i];j++){
        g.es[edge[i][j]]++;
      }
    }
    for(i=1;i<N;i++){
      g.edge[i] = g.edge[i-1] + g.es[i-1];
    }
    *mem = g.edge[N-1] + g.es[N-1];
    for(i=0;i<N;i++){
      g.es[i] = 0;
    }
    for(i=0;i<N;i++){
      for(j=0;j<es[i];j++){
        k = edge[i][j];
        g.edge[k][g.es[k]++] = i;
      }
    }
    return g;
  }
  graph reduce(int tn, int ind[], int self_e = 0, int dep_e = 0, void **mem = &wmem){
    graph g;
    int M=0, i, j, k, x, y;
    pair<int,int> *A;
    for(i=0;i<N;i++){
      M += es[i];
    }
    A = (pair<int,int>*)((int*)((int**)(*mem) + tn) + tn + M);
    M = 0;
    for(i=0;i<N;i++){
      x = ind[i];
      if(x < 0){
        continue;
      }
      for(j=0;j<es[i];j++){
        y = ind[edge[i][j]];
        if(y < 0){
          continue;
        }
        if(self_e==0 && x==y){
          continue;
        }
        A[M++] = make_pair(x, y);
      }
    }
    if(dep_e==0){
      sort(A, A+M);
      k = 0;
      for(i=0;i<M;i++){
        if(k && A[k-1]==A[i]){
          continue;
        }
        A[k++] = A[i];
      }
      M = k;
    }
    g.N = tn;
    g.es = (int*)(*mem);
    g.edge = (int**)(g.es + tn);
    g.edge[0] = (int*)(g.edge + tn);
    for(i=0;i<tn;i++){
      g.es[i] = 0;
    }
    for(i=0;i<M;i++){
      g.es[A[i].first]++;
    }
    for(i=1;i<tn;i++){
      g.edge[i] = g.edge[i-1] + g.es[i-1];
    }
    *mem = g.edge[tn-1] + g.es[tn-1];
    for(i=0;i<tn;i++){
      g.es[i] = 0;
    }
    for(i=0;i<M;i++){
      j = A[i].first;
      k = A[i].second;
      g.edge[j][g.es[j]++] = k;
    }
    return g;
  }
  void getDist(int root, int res[], void *mem = wmem){
    int i, j, k, *q, s, z;
    q=(int*)mem;
    for(i=0;i<N;i++){
      res[i]=-1;
    }
    res[root]=0;
    s=0;
    z=1;
    q[0]=root;
    while(z){
      i=q[s++];
      z--;
      for(j=0;j<es[i];j++){
        k=edge[i][j];
        if(res[k]>=0){
          continue;
        }
        res[k]=res[i]+1;
        q[s+z++]=k;
      }
    }
  }
  inline int sccDFS(int num[], int st, int mx){
    int i, j;
    num[st]=-2;
    for(i=0;i<es[st];i++){
      j=edge[st][i];
      if(num[j]==-1){
        mx=sccDFS(num,j,mx);
      }
    }
    num[st]=mx;
    return mx+1;
  }
  int scc(int res[], void *mem = wmem){
    graph r;
    int i, j, k, *nrv, *num, ret=0, *st, st_size;
    r = reverse(&mem);
    st = (int*)mem;
    num = st+N;
    nrv = num + N;
    for(i=0;i<N;i++){
      res[i] = num[i] = -1;
    }
    k = 0;
    for(i=0;i<N;i++){
      if(num[i]==-1){
        k = sccDFS(num,i,k);
      }
    }
    for(i=0;i<N;i++){
      nrv[num[i]] = i;
    }
    for(k=N-1;k>=0;k--){
      i=nrv[k];
      if(res[i]>=0){
        continue;
      }
      res[i]=ret;
      st_size=0;
      st[st_size++]=i;
      while(st_size){
        i=st[--st_size];
        for(j=0;j<r.es[i];j++){
          if(res[r.edge[i][j]]==-1){
            res[r.edge[i][j]]=ret;
            st[st_size++]=r.edge[i][j];
          }
        }
      }
      ret++;
    }
    return ret;
  }
  inline void bccDFS(int v, int u, int *res, int *rt, int &rts, int *S, int &Ss, int *inS, int *num, int &tm){
    int i, k;
    num[v] = ++tm;
    S[Ss++] = v;
    inS[v] = 1;
    rt[rts++] = v;
    for(i=0;i<es[v];i++){
      int w=edge[v][i];
      if(!num[w]){
        bccDFS(w, v, res, rt, rts, S, Ss, inS, num, tm);
      }
      else if(u != w && inS[w]){
        while(num[rt[rts-1]] > num[w]){
          rts--;
        }
      }
    }
    if(v == rt[rts-1]){
      k = S[Ss-1];
      for(;;){
        int w=S[--Ss];
        inS[w] = 0;
        res[w] = k;
        if(v==w){
          break;
        }
      }
      rts--;
    }
  }
  int bcc(int res[], void *mem=wmem){
    int *S, Ss=0, i, *inS, k, *num, *rt, rts=0, tm=0;
    pair<int,int> *arr;
    num = (int*)mem;
    rt = num + N;
    S = rt + N;
    inS = S + N;
    memset(num, 0, sizeof(int)*N);
    memset(inS, 0, sizeof(int)*N);
    for(i=0;i<N;i++){
      if(!num[i]){
        bccDFS(i, N, res, rt, rts, S, Ss, inS, num, tm);
      }
    }
    arr = (pair<int,int>*)mem;
    for(i=0;i<N;i++){
      arr[i].first = res[i];
      arr[i].second = i;
    }
    sort(arr, arr+N);
    k = 0;
    for(i=0;i<N;i++){
      if(i && arr[i].first != arr[i-1].first){
        k++;
      }
      res[arr[i].second] = k;
    }
    return k+1;
  }
  int shortestPath(const int s, const int t, int res[], void *mem=wmem){
    int *b, i, j, k, *q, qe=0, qs=0;
    b = (int*)mem;
    q = b + N;
    for(i=0;i<N;i++){
      b[i] = -1;
    }
    b[s] = -2;
    q[qe++] = s;
    while(qe > qs){
      i = q[qs++];
      for(j=0;j<es[i];j++){
        k = edge[i][j];
        if(b[k]!=-1){
          continue;
        }
        b[k] = i;
        q[qe++] = k;
      }
      if(b[t]!=-1){
        break;
      }
    }
    if(b[t]==-1){
      return -1;
    }
    k = 0;
    res[k] = i = t;
    while(i != s){
      res[++k] = (i = b[i]);
    }
    std::reverse(res, res+k+1);
    return k;
  }
}
;
char memarr[96000000];
unsigned mint::R, mint::RR, mint::Rinv, mint::W, mint::md, mint::mdninv;
int N;
int K;
int A[200000];
int B[200000];
graph g;
mint dp[200000];
mint solve(int n, int b, int c){
  int i, j, k;
  dp[n] = c;
  j = K - 1;
  if(b!=-1){
    j--;
  }
  for(i=0;i<g.es[n];i++){
    k = g.edge[n][i];
    if(k==b){
      continue;
    }
    dp[n] *= solve(k, n, j);
    j--;
  }
  return dp[n];
}
int main(){
  int i, j, k;
  mint res;
  wmem = memarr;
  {
    mint x;
    x.setmod(MD);
  }
  rd(N);
  rd(K);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<N-1;Lj4PdHRW++){
      rd(A[Lj4PdHRW]);A[Lj4PdHRW] += (-1);
      rd(B[Lj4PdHRW]);B[Lj4PdHRW] += (-1);
    }
  }
  if(N==1){
    wt_L(K);
    wt_L('\n');
    return 0;
  }
  g.setEdge(N,N-1,A,B);
  for(k=0;k<N;k++){
    if(g.es[k]==1){
      break;
    }
  }
  res = solve(k, -1, K);
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190707-1

// --- original code ---
// int N, K, A[2d5], B[2d5];
// graph g;
// 
// mint dp[2d5];
// 
// mint solve(int n, int b, int c){
//   int i, j, k;
// 
//   dp[n] = c;
//   j = K - 1;
//   if(b!=-1) j--;
//   rep(i,g.es[n]){
//     k = g.edge[n][i];
//     if(k==b) continue;
// 
//     dp[n] *= solve(k, n, j);
//     j--;
//   }
// 
//   return dp[n];
// }
// 
// {
//   int i, j, k;
//   mint res;
// 
//   rd(N,K,(A--,B--)(N-1));
// 
//   if(N==1){
//     wt(K);
//     return 0;
//   }
//   
//   g.setEdge(N,N-1,A,B);
//   
//   rep(k,N) if(g.es[k]==1) break;
//   res = solve(k, -1, K);
// 
//   wt(res);
// }


Measured memory_bytes: 13312