mod=10**9+7 n,c=map(int,input().split()) edge=[[]for _ in range(n)] for _ in range(n-1): a,b=map(int,input().split()) a-=1 b-=1 edge[a].append(b) edge[b].append(a) def solve(x): minc=min(2*n-1,x) dp=[minc*[1]for _ in range(n)] def dfs(r,node): for mode in edge[node]: if mode==r:continue dp1=dfs(node,mode) dp[node][0]=(dp[node][0]*dp1[1])%mod dp[node][-1]=(dp[node][-1]*dp1[-2])%mod for i in range(1,minc-1): dp[node][i]=(dp[node][i]*(dp1[i-1]+dp1[i+1]))%mod return dp[node] dfs(-1,0) if minc==x:return sum(dp[0]) else:return sum(dp[0])+(x-minc)*dp[0][minc//2] ans1=solve((c+2)//3) if c>=4 else 0 ans2=solve((c+1)//3) if c>=5 else 0 ans3=solve(c//3) if c>=6 else 0 print(ans1+ans2+ans3)