import sys input = sys.stdin.readline 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 dpsub = dfs(node, mode) dp[node][0] = (dp[node][0] * dpsub[1]) % mod dp[node][minc - 1] = (dp[node][minc - 1] * dpsub[minc - 2]) % mod for i in range(1, minc - 1): dp[node][i] = (dp[node][i] * (dpsub[i - 1]+dpsub[i + 1])) % mod return dp[node] lastdp = dfs(-1, 0) if minc == x: return sum(lastdp) else: return sum(lastdp) + (x - minc) * lastdp[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)