#include using namespace std; #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define REP(i,n) FOR(i,0,n) #define ALL(v) begin(v),end(v) #define fi first #define se second template inline bool chmax(A &a, B b) { if (a inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; } using ll = long long; using pii = pair; constexpr ll INF = 1ll<<30; constexpr ll longINF = 1ll<<60; constexpr ll MOD = 1000000007; constexpr bool debug = 0; //---------------------------------// template struct ModInt { public: using value_type = long long; ModInt(value_type val = 0) : val(val < 0 ? (M - (-val % M)) % M : val % M) {} explicit operator bool() const noexcept { return val; } bool operator ==(const ModInt & rhs) const noexcept { return val == rhs.val; } bool operator !=(const ModInt & rhs) const noexcept { return !(*this == rhs); } ModInt operator +() const noexcept { return ModInt(*this); } ModInt operator -() const noexcept { return ModInt(0) -= *this; } ModInt operator +(const ModInt & rhs) const noexcept { return ModInt(*this) += rhs; } ModInt operator -(const ModInt & rhs) const noexcept { return ModInt(*this) -= rhs; } ModInt operator *(const ModInt & rhs) const noexcept { return ModInt(*this) *= rhs; } ModInt operator /(const ModInt & rhs) const noexcept { return ModInt(*this) /= rhs; } ModInt & operator +=(const ModInt & rhs) noexcept { val += rhs.val; if (val >= M) val -= M; return *this; } ModInt & operator -=(const ModInt & rhs) noexcept { if (val < rhs.val) val += M; val -= rhs.val; return *this; } ModInt & operator *=(const ModInt & rhs) noexcept { val = val * rhs.val % M; return *this; } ModInt & operator /=(const ModInt & rhs) noexcept { *this *= rhs.inverse(); return *this; } ModInt pow(value_type n) const { ModInt res = 1, x = val; if (n < 0) { x = x.inverse(); n = -n; } while (n) { if (n & 1) res *= x; x *= x; n >>= 1; } return res; } ModInt inverse() const { long long a = val, a1 = 1, a2 = 0, b = M, b1 = 0, b2 = 1; while (b > 0) { value_type q = a / b, r = a % b; value_type nb1 = a1 - q * b1, nb2 = a2 - q * b2; a = b; b = r; a1 = b1; b1 = nb1; a2 = b2; b2 = nb2; } assert(a == 1); return a1; } const value_type & get() const noexcept { return val; } static decltype(M) get_mod() noexcept { return M; } friend std::ostream & operator <<(std::ostream & os, const ModInt & rhs) { return os << rhs.val; } friend std::istream & operator >>(std::istream & is, ModInt & rhs) { value_type x; is >> x; rhs = ModInt(x); return is; } private: value_type val; }; using mint = ModInt; int main() { int N, C; cin >> N >> C; vector> g(N); REP(i, N - 1) { int u, v; scanf("%d %d", &u, &v); --u; --v; g[u].emplace_back(v); g[v].emplace_back(u); } vector> done(N, vector(7000)); vector> dp(N, vector(7000)); // [i][j] := 頂点 i の値が j であるときの部分木 i のパターン数 auto dfs = [&](auto && self, int u, int c, int par) -> mint { if (done[u][c]) return dp[u][c]; done[u][c] = true; mint p = 1; for (int v : g[u]) if (v != par) { mint sum = 0; if (c + 3 <= C) sum += self(self, v, c + 3, u); if (c - 3 >= 1) sum += self(self, v, c - 3, u); p *= sum; } return dp[u][c] = p; }; mint ans; if (C < 7000) { FOR(i, 1, C + 1) ans += dfs(dfs, 0, i, -1); } else { FOR(i, 1, 3501) ans += dfs(dfs, 0, i, -1) * 2; ans += dfs(dfs, 0, 3500, -1) * (C - 7000); } cout << ans << endl; return 0; }