#include #define rep(i,n) for (int i = 0; i < (int)(n); i ++) #define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i) using namespace std; using ll = long long; using PL = pair; using P = pair; constexpr int INF = 1000000000; constexpr long long HINF = 1000000000000000; constexpr long long MOD = 1000000007;// = 998244353; constexpr double EPS = 1e-4; constexpr double PI = 3.14159265358979; template struct ModInt { long long x; ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {} constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;} constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;} constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;} constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();} constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;} constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;} constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;} constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;} friend constexpr ostream& operator<<(ostream& os,const ModInt& a) {return os << a.x;} friend constexpr istream& operator>>(istream& is,ModInt& a) {return is >> a.x;} ModInt inverse() const {// x ^ (-1) long long a = x,b = Modulus,p = 1,q = 0; while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);} return ModInt(p); } ModInt pow(long long N) {// x ^ N ModInt a = 1; while (N) { if (N&1) a *= *this; *this *= *this; N >>= 1; } return a; } }; using mint = ModInt<1000000007>; int N,M; vector> G(N); vector> dp; vector> visited; mint dfs(int v,int c,int p = -1) { if (visited[v][c] >= 0) return dp[v][c]; visited[v][c] = 1; mint ans = 1; for (int e:G[v]) { if (e == p) continue; mint ret = 0; if (c - 3 > 0) ret += dfs(e,c-3,v); if (c + 3 <= M) ret += dfs(e,c+3,v); ans *= ret; } return dp[v][c] = ans; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll C; cin >> N >> C; M = min((ll)6*N + 10,C); G.resize(N); dp.assign(N,vector(M + 1,0)); visited.assign(N,vector(M + 1,-1)); rep(i,N - 1) { int a,b; cin >> a >> b; --a; --b; G[a].push_back(b); G[b].push_back(a); } int K = min((ll)3*N + 3,C); rep(i,K) dfs(0,i + 1); mint ans = 0; if (C <= K) { rep(i,C) ans += dp[0][i + 1]; cout << ans << '\n'; } else if (C < 2*K){ rep(i,K) ans += dp[0][i + 1]; rep(i,C - K) ans += dp[0][i + 1]; cout << ans << '\n'; } else { rep(i,K) ans += mint(2)*dp[0][i + 1]; ans += mint(C - 2*K) * dp[0][K]; cout << ans << '\n'; } return 0; }