#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,a[N],s;
signed main(){
	scanf("%lld%lld",&n,&a[1]);s+=a[1];
	for (int i=2;i<=n;i++)a[i]=a[1],s+=a[i];
	dp[n][0]++;
	for (int i=n;i;i--)
		for (int j=0;j<=s;j++)
			if (dp[i][j])for (int k=0;k<=a[i];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<=s;j++)(ans+=M-dp[0][j]*j%M)%=M;
	int fac=1;
	for (int i=1;i<=n;i++){
		int fac=1;
		for (int j=1;j<=n;j++)
			if (j!=i)(fac*=a[j]+1)%=M;
		for (int j=0;j<=a[i];j++)(ans+=fac*j)%=M;	
	}
	printf("%lld\n",ans);
	return 0;
}