#i hate three from collections import deque import sys sys.setrecursionlimit(10**7) mod = 10**9 + 7 def main(): N, C = map(int, input().split()) G = [[] for i in range(N+1)] for i in range(N-1): a, b = map(int, input().split()) G[a].append(b) G[b].append(a) visited = [False for i in range(N+1)] depth = [0 for i in range(N+1)] child_cnt = [1 for i in range(N+1)] que = deque([]) def dfs(s_node): visited[s_node] = True for child in G[s_node]: if visited[child] == False: depth[child] = depth[s_node] + 1 dfs(child) for child in G[s_node]: if depth[child] > depth[s_node]: child_cnt[s_node] += child_cnt[child] que.append(s_node) dfs(1) if C > 8*N: dp = [[0 for i in range(6*N-5)] for i in range(N+1)] while que: node = que.popleft() for i in range(3*N-4): has_child = False v = 1 for child in G[node]: if depth[child] > depth[node]: tmp_u = 0 has_child = True if i >= 3: tmp_u += dp[child][i-3] if i+3 <= 3*N-5: tmp_u += dp[child][i+3] elif i+3 > 3*N-5: tmp_u += pow(2, child_cnt[child]-1, mod) v *= tmp_u v %= mod dp[node][i] = v if has_child == False: dp[node][i] = 1 for i in range(3*N-3, 6*N-5): has_child = False v = 1 for child in G[node]: if depth[child] > depth[node]: tmp_u = 0 has_child = True if i+3 <= 6*N-6: tmp_u += dp[child][i+3] if i-3 >= 3*N-3: tmp_u += dp[child][i-3] else: tmp_u += pow(2, child_cnt[child]-1, mod) v *= tmp_u v %= mod dp[node][i] = v if has_child == False: dp[node][i] = 1 ans = sum(dp[1][i] for i in range(3*N-4)) + sum(dp[1][i] for i in range(3*N-3, 6*N-5)) + (C-6*N + 6)*pow(2, N-1, mod) print(ans % mod) return elif C <= 8*N: dp = [[0 for i in range(C+1)] for j in range(N+1)] while que: node = que.popleft() for i in range(1, C+1): has_child = False v = 1 for child in G[node]: if depth[child] > depth[node]: has_child = True tmp_u = 0 if 1 <= i-3 <= C: tmp_u += dp[child][i-3] if 1 <= i+3 <= C: tmp_u += dp[child][i+3] v *= (tmp_u) dp[node][i] = v % mod if has_child == False: dp[node][i] = 1 ans = sum(dp[1][i] for i in range(1, C+1)) % mod print(ans) return if __name__ == "__main__": main()