#include #include #include using namespace std; using namespace atcoder; using mint = modint1000000007; #define rep(i,n) for (int i = 0; i < (n); ++i) #define modulo 1000000007 #define mod(mod_x) ((((long long)mod_x+modulo))%modulo) #define Inf 10000000000000 int N; vector> E; int C; vector> dp1; vector> dp2; vector> dp3; int t0,t1,t2; void dfs(int now,int p){ rep(i,dp1[now].size()){ dp1[now][i] = 1; } rep(i,dp2[now].size()){ dp2[now][i] = 1; } if(dp1[now].size()+dp2[now].size()=0)t += dp1[to][j-3]; if(j+3=0)t += dp2[to][j-3]; if(j+3>N>>C; E.resize(N,vector()); rep(i,N-1){ int a,b; scanf("%d %d",&a,&b); a--;b--; E[a].push_back(b); E[b].push_back(a); } dp1.resize(N,vector(min(C,3000),0)); dp2.resize(N,vector(max(0,min(C-(int)dp1[0].size(),3000)),0)); dp3.resize(N,vector(3,0)); dfs(0,-1); mint ans = 0; rep(i,dp1[0].size()){ ans += dp1[0][i]; } rep(i,dp2[0].size()){ ans += dp2[0][i]; } int t = 1 + C - dp1[0].size() - dp2[0].size();; if(t>0)ans += dp3[0][0] * t; cout<