#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
using namespace std;

const int mod = 1000000007;

long long dp[101][4000];
int main() {
	int n, k;
	scanf("%d %d", &n, &k);
	long long ans = (n * (k * (k + 1) / 2)) % mod;
	for (int i = 0; i < n - 1; ++ i)
		(ans *= (k + 1)) %= mod;
	for (int i = 0; i < 4000; ++ i)
		dp[n][i] = 0;
	dp[n][0] = 1;
	for (int i = n; i > 0; -- i)
		for (int j = 0; j < 4000; ++ j)
			for (int a = 0; a <= k; ++ a)
				if (a <= i)
					(dp[i - 1][j + (a + j) / i] += dp[i][j]) %= mod;
				else
					(dp[i - 1][j] += dp[i][j]) %= mod;
	for (int j = 0; j < 4000; ++ j)
		ans = (ans + mod - j * dp[0][j] % mod) % mod;
	printf("%lld\n", ans);
	return 0;
}