#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,m; 
const int mod=1e9+7;
const ll MOD=1e9+7;
int dp[103][10004];
int main(){
	ll a=1;
	cin>>n>>m;
	for (int i=0;i<n-1;i++) a=a*(m+1)%MOD;
	dp[n+1][0]=1;
	for (int i=n;i>=1;i--)
		for (int j=0;j<=m;j++)
			for (int k=0;k<=10000;k++){	
				if (j>i){
					dp[i][k]=(dp[i+1][k]+dp[i][k])%mod;
					continue;
				}
				int x=(j+k)/i;
				if (x+k>10000) continue;
				dp[i][x+k]=(dp[i+1][k]+dp[i][x+k])%mod;
			}
	ll res=a*m*(m+1)/2*n%MOD;
	for (int i=0;i<=10000;i++)
		res=(res-1ll*dp[1][i]*i+MOD)%MOD;
	cout<<res;
}