#include"iostream" #include"algorithm" #include"cstring" #include"cstdio" #include"vector" usingnamespace std; #define int long long #define MAXN 5006 #define P 1000000007 int n , m; int dp[MAXN][MAXN][2] , siz[MAXN] , t[MAXN][2]; vector<int> G[MAXN]; voiddfs( int u , int fa ){ siz[u] = 1; dp[u][1][0] = dp[u][1][1] = 1; for( int v : G[u] ) if( v != fa ) { dfs( v , u ); for( int i = 1 ; i <= siz[u] + siz[v] ; ++ i ) t[i][0] = t[i][1] = 0; for( int i = 1 ; i <= siz[u] ; ++ i ) for( int j = 1 ; j <= siz[v] ; ++ j ) ( t[i + j][0] += 1ll * dp[u][i][0] * dp[v][j][1] ) %= P, ( t[i + j][1] += 1ll * dp[u][i][1] * dp[v][j][1] ) %= P, ( t[i + j - 1][0] += 1ll * dp[u][i][0] * dp[v][j][0] ) %= P, ( t[i + j - 1][1] += ( 1ll * dp[u][i][0] * dp[v][j][1] % P + 1ll * dp[u][i][1] * dp[v][j][0] % P ) % P ) %= P; siz[u] += siz[v]; for( int i = 1 ; i <= siz[u] ; ++ i ) dp[u][i][0] = t[i][0] , dp[u][i][1] = t[i][1]; } } intPow( int x , int a ){ int cur = x % P , ans = 1; while( a ) { if( a & 1 ) ans = 1ll * ans * cur % P; cur = 1ll * cur * cur % P , a >>= 1; } return ans; } int J[MAXN] , invJ[MAXN] , re[MAXN]; intC( int a , int b ){ return1ll * J[a] * invJ[b] % P * invJ[a - b] % P; } signedmain(){ cin >> n >> m; m = max( 0ll , n - 1 - m ); J[0] = invJ[0] = 1; for( int i = 1 ; i < MAXN ; ++ i ) J[i] = 1ll * J[i - 1] * i % P , invJ[i] = Pow( J[i] , P - 2 ); for( int i = 1 , u , v ; i < n ; ++ i ) { scanf("%lld%lld",&u,&v) , G[u].push_back( v ) , G[v].push_back( u ); } dfs( 1 , 1 ); int t = Pow( n , P - 2 ); for( int i = 1 ; i <= n ; ++ i ) re[i] = 1ll * dp[1][i][1] * t % P , t = 1ll * t * n % P; int res = 0; for( int i = m ; i < n ; ++ i ) { int r = 0; for( int j = i ; j < n ; ++ j ) ( r += 1ll * C( j , i ) * re[n - j] % P * ( ( j - i & 1 ) ? P - 1 : 1 ) % P ) %= P; ( res += r ) %= P; } cout << res << endl; }