#include <iostream>
using namespace std;
long long dp[109][5509], N, K, mod = 1000000007;
int main() {
	cin >> N >> K; dp[N][0] = 1;
	for (int i = N; i >= 1; i--) {
		for (int j = 0; j <= N*(N + 1) / 2; j++) {
			if (dp[i][j] == 0)continue;
			for (int k = 0; k <= K; k++) {
				if (i < k) {
					dp[i - 1][j] += dp[i][j];
					dp[i - 1][j] %= mod;
				}
				else {
					int Z = j + k; Z /= i;
					dp[i - 1][j + Z] += dp[i][j];
					dp[i - 1][j + Z] %= mod;
				}
			}
		}
	}
	long long R = 1;
	for (int i = 0; i < N; i++) { R *= (K + 1); R %= mod; }
	R *= K*N; R %= mod; if (R % 2 == 1)R += mod; R /= 2;
	for (int i = 0; i <= N*(N + 1) / 2; i++) {
		R -= dp[0][i] * i; R = (R + mod*mod) % mod;
	}
	cout << R << endl;
	return 0;
}