#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=105,M=1e9+7;
int n,m,dp[N][N*N],ans;
signed main(){
	scanf("%lld%lld",&n,&m);
	dp[n][0]++;
	for (int i=n;i;i--)
		for (int j=0;j<=(n-i+1)*m;j++)
			if (dp[i][j])for (int k=0;k<=m;k++)
				if (k<=i)(dp[i-1][j+(k+j)/i]+=dp[i][j])%=M;
				else (dp[i-1][j]+=dp[i][j])%=M;
	for (int j=0;j<=n*m;j++)(ans+=M-dp[0][j]*j%M)%=M;
	int fac=1;		
	for (int i=1;i<n;i++)(fac*=m+1)%=M;
	for (int i=0;i<=m;i++)(ans+=fac*n%M*i)%=M;
	printf("%lld\n",ans);
}