#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define sz size() #define pb push_back #define mp make_pair #define fi first #define se second #define all(c) (c).begin(), (c).end() #define rep(i,a,b) for(ll i=(a);i<(b);++i) #define per(i,a,b) for(ll i=b-1LL;i>=(a);--i) #define clr(a, b) memset((a), (b) ,sizeof(a)) #define ctos(c) string(1,c) #define endl "\n" #define print(x) cout<<#x<<" = "<= MOD)r %= MOD; a *= a; if(a >= MOD)a %= MOD; b >>= 1LL; } return r%MOD; } vector > vv; void dfs1(ll a, ll p){ rep(i,1,1005){ ll b = 1; rep(j,0,vv[a].sz){ if(vv[a][j]==p)continue; if(i==1)dfs1(vv[a][j],a); b *= dp1[vv[a][j]][i]; b %= MOD; } dp1[a][i] = dp1[a][i-1]+b; dp1[a][i] %= MOD; } } void dfs2(ll a, ll p){ ll e = 0; rep(i,1,1005){ if(p==-1){ dp2[a][i] = dp1[a][i]; dp3[a][i] = MOD+dp1[a][i]-dp1[a][i-1]; dp3[a][i] %= MOD; } else{ dp3[a][i] = e*(MOD+dp1[a][i]-dp1[a][i-1]); dp3[a][i] %= MOD; ll b = (MOD+dp2[p][i]-dp2[p][i-1])%MOD; b *= modpow(dp1[a][i],MOD-2); b %= MOD; b += e; b %= MOD; e = b; dp2[a][i] = b*(MOD+dp1[a][i]-dp1[a][i-1]); dp2[a][i] += dp2[a][i-1]; dp2[a][i] %= MOD; } } rep(j,0,vv[a].sz){ if(vv[a][j]==p)continue; dfs2(vv[a][j],a); } } int main(){ ll n,k; cin>>n>>k; vector > vv_(n,vector()); vv = vv_; rep(i,0,n-1){ ll a,b; cin>>a>>b; a--;b--; vv[a].pb(b); vv[b].pb(a); } clr(dp1,0); clr(dp2,0); clr(dp3,0); dfs1(0,-1); dfs2(0,-1); ll ans = 0; rep(i,0,n){ rep(j,1,k+1){ ans += dp3[i][j]; ans %= MOD; } } cout << ans << endl; return 0; }