#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;

#define fi first
#define se second
#define mp make_pair
#define pb push_back

#define P 1000000007
#define N 110
#define MM 4010
int f[N][MM];
int n, kk;

int main() {
	/*
	int sg = 0;
	for (int i = 100; i >= 1; i--) {
		sg += (sg + i)/i;
	}
	cout << sg << endl;
	*/
	cin >> n >> kk;
	f[n][0] = 1;
	for (int i = n-1; i >= 0; i--)
		for (int j = 0; j < MM; j ++) if (f[i+1][j]) {
			for (int k = 0; k <= kk; k ++) {
				int sg = j;
				if (k <= i+1) sg = j + (j + k)/(i+1);
				(f[i][sg] += f[i+1][j]) %= P;
			}
		}
	//for (int i = 0; i < MM; i ++)
	//	if (f[0][i]) printf ("%d %d\n", i, f[0][i]);
	int S = 0;
	for (int i = 0; i < MM; i ++)
		S = (S + (ll)f[0][i]*i%P)%P;
	int T = (ll)kk*(P+1)/2%P;
	T = (ll)T*n%P;
	for (int i = 0; i < n; i ++)
		T = (ll)T*(kk+1)%P;
	printf ("%d\n", (T-S+P)%P);
	return 0;
}