#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
ll ans=0,n,k,dp[105][10005],i,j,u,num;
const ll mod=1e9+7;
ll pow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
ll M(ll x){return x>=mod?x-mod:x;}
int main()
{
	scanf("%lld%lld",&n,&k);
	ans=n*(1LL+k)*k/2LL*pow(k+1LL,n-1LL)%mod;
	dp[n+1][0]=1;
	for(i=n;i>0;i--)
	{
		for(j=0;j<=(n-i)*k;j++)
		{
			for(u=0;u<=k;u++)
			{
				if(u>i||i-u>j)num=0;
				else num=1+(j-(i-u))/i;
				dp[i][j+num]=M(dp[i][j+num]+dp[i+1][j]);
			}
		}
	}
	//printf("%lld\n",ans);
	//for(i=1;i<=n;i++)for(j=0;j<=n;j++)printf("%lld %lld %lld\n",i,j,dp[i][j]);
	for(i=1;i<=n*k;i++)ans=M(ans-dp[1][i]*i%mod+mod);
	printf("%lld\n",ans);
	return 0;
}