#pragma GCC optimize("Ofast") #include using namespace std; #define rep(i, n) for(int i = 0; i < (n); ++i) #define all(x) (x).begin(),(x).end() #define ln '\n' constexpr long long MOD = 1000000007LL; //constexpr long long MOD = 998244353LL; typedef long long ll; typedef unsigned long long ull; typedef pair pii; typedef pair pll; template inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; } template inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; } //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// template struct ModInt { using u64 = std::uint_fast64_t; u64 a; constexpr ModInt(const long long x = 0) noexcept : a(x >= 0 ? x % Modulus : (Modulus - (-x) % Modulus) % Modulus) {} constexpr u64 &value() noexcept { return a; } constexpr const u64 &value() const noexcept { return a; } constexpr ModInt operator+(const ModInt rhs) const noexcept {return ModInt(*this) += rhs;} constexpr ModInt operator-(const ModInt rhs) const noexcept {return ModInt(*this) -= rhs;} constexpr ModInt operator*(const ModInt rhs) const noexcept {return ModInt(*this) *= rhs;} constexpr ModInt operator/(const ModInt rhs) const noexcept {return ModInt(*this) /= rhs;} constexpr ModInt &operator+=(const ModInt rhs) noexcept { a += rhs.a; if (a >= Modulus) { a -= Modulus; } return *this; } constexpr ModInt &operator-=(const ModInt rhs) noexcept { if (a < rhs.a) { a += Modulus; } a -= rhs.a; return *this; } constexpr ModInt &operator*=(const ModInt rhs) noexcept { a = a * rhs.a % Modulus; return *this; } constexpr ModInt &operator/=(ModInt rhs) noexcept { u64 exp = Modulus - 2; while (exp) { if (exp % 2) { *this *= rhs; } rhs *= rhs; exp /= 2; } return *this; } bool operator==(const ModInt &p) const {return a == p.a;} bool operator!=(const ModInt &p) const {return a != p.a;} ModInt pow(long long N) const { ModInt ret(1), mul(a); while(N > 0) { if(N & 1) ret *= mul; mul *= mul; N >>= 1; } return ret; } }; using mint = ModInt; mint ans[2020][2020]; vector G[2020]; int sub[2020]; void dfs(int v, int pv) { vector arr(2020); int sz = 1; arr[0] = 1; for (auto nv : G[v]) { if (nv==pv) continue; vector dp2(2020); dfs(nv,v); rep(i,sz) { rep(j,sub[nv]+1) { dp2[i+j] += arr[i]*ans[nv][j]; } } swap(arr,dp2); sz += sub[nv]; } sub[v] = sz; rep(i,sub[v]) ans[v][i] = arr[i]; ans[v][sub[v]] = 1; return; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N,K; cin >> N >> K; rep(i,N-1) { int u,v; cin >> u >> v; G[u].emplace_back(v); G[v].emplace_back(u); } dfs(0,-1); cout << ans[0][K].a << ln; }