#include using namespace std; long long MOD = 1000000007; vector parent(vector> &E, int r){ int N = E.size(); vector p(N, -1); queue Q; Q.push(r); while (!Q.empty()){ int v = Q.front(); Q.pop(); for (int w : E[v]){ if (p[w] == -1){ p[w] = v; Q.push(w); } } } return p; } vector> child(vector> E, int r){ int N = E.size(); vector> c(N); queue Q; Q.push(r); while (!Q.empty()){ int v = Q.front(); Q.pop(); for (int w : E[v]){ if (c[w].empty()){ c[v].push_back(w); Q.push(w); } } } return c; } void dfs1(vector> &dp1, vector> &c, int K, int v){ for (int i = 0; i < K; i++){ dp1[v][i] = 1; } for (int w : c[v]){ dfs1(dp1, c, K, w); for (int i = 0; i < K; i++){ dp1[v][i] *= dp1[w][i]; dp1[v][i] %= MOD; } } for (int i = 1; i < K; i++){ dp1[v][i] += dp1[v][i - 1]; dp1[v][i] %= MOD; } return; } void dfs2(vector> &dp1, vector> &dp2, vector> &c, int K, int v){ int deg = c[v].size(); vector> L(deg + 1, vector(K, 1)); for (int i = 0; i < deg; i++){ L[0][0] = 0; for (int j = 0; j < K; j++){ L[i + 1][j] = L[i][j] * dp1[c[v][i]][j] % MOD; } } vector> R(deg + 1, vector(K, 1)); for (int i = deg - 1; i >= 0; i--){ R[i][0] = 0; for (int j = 0; j < K; j++){ R[i][j] = R[i + 1][j] * dp1[c[v][i]][j] % MOD; } } for (int i = 0; i < deg; i++){ for (int j = 0; j < K; j++){ dp2[c[v][i]][j] = L[i][j] * R[i + 1][j] % MOD * dp1[v][j] % MOD; dfs2(dp1, dp2, c, K, c[v][i]); } } return; } int main(){ int N, K; cin >> N >> K; vector> E(N); for (int i = 0; i < N - 1; i++){ int a, b; cin >> a >> b; a--; b--; E[a].push_back(b); E[b].push_back(a); } vector p = parent(E, 0); vector> c = child(E, 0); vector> dp1(N, vector(K, 1)); dfs1(dp1, c, K, 0); /* for (int i = 0; i < N; i++){ cout << "i = " << i << endl; for (int j = 0; j < K; j++){ cout << dp1[i][j] << ' '; } cout << endl; } */ vector> dp2(N, vector(K, 1)); dfs2(dp1, dp2, c, K, 0); long long ans = 0; for (int i = 0; i < N; i++){ ans += dp1[i][K - 1] * dp2[i][K - 1] % MOD; ans %= MOD; } cout << ans << endl; }