#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } template struct ModInt { static const int Mod = MOD; unsigned x; ModInt(): x(0) { } ModInt(signed sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } ModInt(signed long long sig) { int sigt = sig % MOD; if(sigt < 0) sigt += MOD; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } }; typedef ModInt<1000000007> mint; vector g; vector dfs(int i, int j, bool first, int p) { if(g[i].size() == j) { vector res(1 + first); res[0] = 1; if(first) res[1] = 1; return res; } if(g[i][j] == p) return dfs(i, j+1, first, p); vector left = dfs(g[i][j], 0, true, i); vector right = dfs(i, j+1, false, i); int leftsize = left.size() - 1, rightsize = right.size() - 1; vector res(leftsize + rightsize + first + 1); rep(k, leftsize + rightsize + 1) { mint x; int maxl = min(k, leftsize), minl = max(0, k - rightsize); for(int l = minl; l <= maxl; l ++) x += left[l] * right[k - l]; res[k] += x; if(first && k == leftsize + rightsize) res[k+1] += x; } // cerr << i << ", " << j << ": "; rep(k, res.size()) cerr << res[k].get() << ", "; cerr << endl; return res; } int main() { int N, K; scanf("%d%d", &N, &K); g.assign(N, vi()); rep(i, N-1) { int a, b; scanf("%d%d", &a, &b); // a=i+1,b=rand()%(i+1); g[a].push_back(b); g[b].push_back(a); } vector v = dfs(0, 0, true, -1); mint ans = K > N ? 0 : v[K]; printf("%d\n", ans.get()); return 0; }