#include using namespace std; #define debug(x) cerr << #x << ": " << x << endl #define debugArray(x, n) \ for (long long hoge = 0; (hoge) < (n); ++(hoge)) \ cerr << #x << "[" << hoge << "]: " << x[hoge] << endl template struct Tree_DP { struct Edge { int to; E data; T dp, ndp; }; using F = function; using G1 = function; using G2 = function; private: vector> graph; vector subdp, dp; const T ti; const F f; const G1 g1; const G2 g2; private: void dfs_sub(int idx, int par) { for (auto &e : graph[idx]) { if (e.to == par) continue; dfs_sub(e.to, idx); subdp[idx] = f(subdp[idx], g1(subdp[e.to], e.data)); } subdp[idx] = g2(subdp[idx], idx); } void dfs_all(int idx, int par, const T &top) { T buff{ti}; for (int i = 0; i < (int)graph[idx].size(); i++) { auto &e = graph[idx][i]; e.ndp = buff; e.dp = g1(par == e.to ? top : subdp[e.to], e.data); buff = f(buff, e.dp); } dp[idx] = g2(buff, idx); buff = ti; for (int i = (int)graph[idx].size() - 1; i >= 0; i--) { auto &e = graph[idx][i]; if (e.to != par) dfs_all(e.to, idx, f(e.ndp, buff)); e.ndp = f(e.ndp, buff); buff = f(buff, e.dp); } } public: Tree_DP(int V, const F f, const G1 g1, const G2 g2, T ti) : graph(V), f(f), g1(g1), g2(g2), ti(ti), subdp(V, ti), dp(V, ti) {} void add_edge(int u, int v, E d, E e) { graph[u].emplace_back((Edge){v, d, ti, ti}); graph[v].emplace_back((Edge){u, e, ti, ti}); } void add_edge(int u, int v, E d) { add_edge(u, v, d, d); } vector build(int root) { dfs_sub(root, -1); return subdp; } vector build_rerooting() { dfs_sub(0, -1); dfs_all(0, -1, ti); return dp; } }; template struct ModInt { int x; ModInt() : x(0) {} ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {} ModInt &operator+=(const ModInt &p) { if ((x += p.x) >= mod) x -= mod; return *this; } ModInt &operator-=(const ModInt &p) { if ((x += mod - p.x) >= mod) x -= mod; return *this; } ModInt &operator*=(const ModInt &p) { x = (int)(1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt &p) { return *this *= p.inverse(); } ModInt operator-() const { return ModInt() - *this; } ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; } ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; } ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; } ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; } bool operator==(const ModInt &p) const { return x == p.x; } bool operator!=(const ModInt &p) const { return x != p.x; } ModInt inverse() const { int a = x, b = mod, u = 1, v = 0, t; while (b) t = a / b, swap(a -= t * b, b), swap(u -= t * v, v); return ModInt(u); } ModInt pow(int64_t e) const { ModInt ret(1); for (ModInt b = *this; e; e >>= 1, b *= b) if (e & 1) ret *= b; return ret; } friend ostream &operator<<(ostream &os, const ModInt &p) { return os << p.x; } friend istream &operator>>(istream &is, ModInt &a) { int64_t t; is >> t; a = ModInt(t); return (is); } static int modulo() { return mod; } }; signed main() { cin.tie(0); ios::sync_with_stdio(0); using Mint = ModInt; int N, K; cin >> N >> K; auto f = [](const vector &lhs, const vector &rhs) { vector ret(lhs.size() + rhs.size() - 1, 0); for (int i = 0; i < lhs.size(); i++) { for (int j = 0; j < rhs.size(); j++) { ret[i + j] += lhs[i] * rhs[j]; } } return ret; }; auto g1 = [](const vector &dp, int dat) { return dp; }; auto g2 = [](const vector &dp, int v) { auto ret = dp; ret.emplace_back(1); return ret; }; Tree_DP, int> graph(N, f, g1, g2, {1}); for (int i = 0; i < N - 1; i++) { int a, b; cin >> a >> b; graph.add_edge(a, b, 0); } auto ans = graph.build(0); cout << ans[0][K] << endl; return 0; }