import sys sys.setrecursionlimit(2000) input = sys.stdin.readline 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] 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) c1 = (c + 2) // 3 c2 = (c + 1) // 3 c3 = c // 3 ans1 = solve(c1) if c1 == c2: ans2 = ans1 elif c2 == 1: ans2 = 0 else: ans2 = solve(c2) if c2 == c3: ans3 = ans2 elif c3 == 1: ans3 = 0 else: ans3 = solve(c3) print((ans1 + ans2 + ans3) % mod)