#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() #define fi first #define se second typedef long long ll; typedef vector vec; typedef vector mat; ll N,M,H,W,Q,K,A,B; string S; typedef pair P; const ll INF = (1LL<<60); template class modint{ public: ll x; constexpr modint(){x = 0;} constexpr modint(ll _x) : x((_x < 0 ? ((_x += (LLONG_MAX / mod) * mod) < 0 ? _x + (LLONG_MAX / mod) * mod : _x) : _x)%mod){} constexpr modint operator-(){ return x == 0 ? 0 : mod - x; } constexpr modint& operator+=(const modint& a){ if((x += a.x) >= mod) x -= mod; return *this; } constexpr modint operator+(const modint& a) const{ return modint(*this) += a; } constexpr modint& operator-=(const modint& a){ if((x -= a.x) < 0) x += mod; return *this; } constexpr modint operator-(const modint& a) const{ return modint(*this) -= a; } constexpr modint& operator*=(const modint& a){ (x *= a.x)%=mod; return *this; } constexpr modint operator*(const modint& a) const{ return modint(*this) *= a; } constexpr modint pow(unsigned long long pw) const{ modint res(1), comp(*this); while(pw){ if(pw&1) res *= comp; comp *= comp; pw >>= 1; } return res; } //以下、modが素数のときのみ constexpr modint inv() const{ return modint(*this).pow(mod - 2); } constexpr modint& operator/=(const modint &a){ (x *= a.inv().x)%=mod; return *this; } constexpr modint operator/(const modint &a) const{ return modint(*this) /= a; } }; #define mod2 1000000007 using mint = modint; ostream& operator<<(ostream& os, const mint& a){ os << a.x; return os; } using vm = vector; void dfs(int v, int p, ll len, vector &dp, mat &G){ rep(i, min(N * 2 + 1, len)) dp[v][i] = 1; for(int to : G[v]){ if(to != p){ rep(i, (int)dp[v].size()) { mint temp(0); if (i != 0) temp += dp[to][i - 1]; if (i != N * 2) temp += dp[to][i + 1]; dp[v][i] *= temp; } } } } int main() { cin>>N>>K; ll lw = K/3, hi = (K + 2) / 3; mat G(N, vec(0)); rep(i, N - 1){ int a, b; cin>>a>>b; --a; --b; G[a].push_back(b); G[b].push_back(a); } vector v_lw(N, vm(N * 2 + 1, 0)), v_hi(N, vm(N * 2 + 1, 0)); dfs(0, -1, lw, v_lw, G); dfs(0, -1, hi, v_hi, G); int high_num = (K%3 ? K%3 : 3); mint res(0); rep(i, 3){ res += (i < high_num) ? accumulate(ALL(v_hi[0]), mint(0)) + v_hi[0][N] * max(0LL, hi - (N * 2 + 1)) : accumulate(ALL(v_lw[0]), mint(0)) + v_lw[0][N] * max(0LL, lw - (N * 2 + 1)); } cout<