#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=305,mod=1e9+7;
ll dp[N][N*N],sum[N][N*N];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    dp[n+1][0]=1;
    int mx=0;
    for(int i=n+1;i>1;i--)
    {
        int t=mx;
        for(int j=0;j<=t;j++)
        {
            if(!dp[i][j]&&!sum[i][j]) continue;
            for(int h=0;h<=k;h++)
            {
                if(h<=i-1)
                {
                    mx=max(mx,j+(h+j)/(i-1));
                    int s=j+(h+j)/(i-1);
                    dp[i-1][s]=(dp[i-1][s]+dp[i][j])%mod;
                    sum[i-1][s]=(sum[i-1][s]+sum[i][j]+(h+j)%(i-1)*dp[i][j])%mod;
                }
                else
                {
                    dp[i-1][j]=(dp[i-1][j]+dp[i][j])%mod;
                    sum[i-1][j]=(sum[i-1][j]+sum[i][j]+(h+j)*dp[i][j]%mod)%mod;
                }
            }
        }
    }
    ll ans=0;
    for(int j=0;j<=mx;j++)
        ans=(ans+sum[1][j])%mod;
    printf("%lld\n",ans);
}
