#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; templatestruct Modint { private: unsigned int value; public: constexpr Modint(const long long x = 0) noexcept { long long y = x; if(y < 0 || y >= MOD) { y %= MOD; if(y < 0) y += MOD; } value = (unsigned int)y; } constexpr unsigned int &val() noexcept {return value;} constexpr Modint operator+(const Modint &other) noexcept { Modint tmp = *this; return tmp += other; } constexpr Modint operator-(const Modint &other) noexcept { Modint tmp = *this; return tmp -= other; } constexpr Modint operator*(const Modint &other) noexcept { Modint tmp = *this; return tmp *= other; } constexpr Modint operator/(const Modint &other) noexcept { Modint tmp = *this; return tmp /= other; } constexpr Modint &operator+=(const Modint &other) noexcept { value += other.value; if(value >= MOD) value -= MOD; return *this; } constexpr Modint &operator-=(const Modint &other) noexcept { unsigned long long x = value; if(x < other.value) x += MOD; x -= other.value; value = (unsigned int) x; return *this; } constexpr Modint &operator*=(const Modint &other) noexcept { unsigned long long x = value; x *= other.value; value = (unsigned int)(x%MOD); return *this; } constexpr Modint &operator/=(const Modint &other) noexcept { return *this = *this * other.inverse(); } constexpr Modint power(long long ex) const noexcept { assert(ex >= 0); Modint p = *this,res = 1; while(ex) { if(ex & 1) res *= p; p *= p; ex >>= 1; } return res; } constexpr Modint inverse() const noexcept { assert(value); long long a = value,b = MOD,x = 1,y = 0; while(b) { long long q = a/b; a -= q*b; swap(a,b); x -= q*y; swap(x,y); } return Modint(x); } constexpr Modint &operator++(int) noexcept {return *this += 1;} constexpr Modint &operator--(int) noexcept {return *this -= 1;} constexpr bool operator==(const Modint &other){return value == other.value;} constexpr bool operator!=(const Modint &other){return value != other.value;} template friend ostream &operator<<(ostream &os,const Modint &x); }; template ostream &operator<<(ostream &os,const Modint &x){os << x.value; return os;} //using mint = Modint<998244353>; using mint = Modint<1000000007>; int N,K,ch[2000]; vector G[2000]; mint dp[2000][2001]; void dfs(int u,int p) { ch[u] = 1; mint ep[2][2001]; int now = 0; for(int i = 0;i <= N;i++) ep[now][i] = 0; ep[now][0] = 1; for(int v:G[u]) if(v != p) { dfs(v,u); int nxt = 1-now; for(int i = 0;i <= ch[u]+ch[v];i++) ep[nxt][i] = 0; for(int i = 0;i < ch[u];i++)for(int j = 0;j <= ch[v];j++) ep[nxt][i+j] += ep[now][i]*dp[v][j]; now = nxt; ch[u] += ch[v]; } for(int i = 0;i <= N;i++) dp[u][i] = ep[now][i]; dp[u][ch[u]] = 1; } void solve() { cin >> N >> K; for(int i = 1;i < N;i++) { int u,v; cin >> u >> v; G[u].push_back(v); G[v].push_back(u); } dfs(0,-1); cout << dp[0][K] << "\n"; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int T = 1; //cin >> T; while(T--) solve(); }