// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>

using namespace std;

#define rep(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline bool smin(T &a, const T &b)   { return a > b ? a = b : a;    }
template<typename T> inline bool smax(T &a, const T &b)   { return a < b ? a = b : a;    }

typedef long long LL;

const int N = (int) 105, mod = (int) 1e9 + 7;
int dp[N * N], odp[N * N];
void sadd(int &x, int y) {
	x += y;
	while (x >= mod) x -= mod;
}
int main() {
	int n, k;
	cin >> n >> k;
	int sum_all = n * (k + 1) * k / 2;
	for (int x = 0; x < n - 1; ++x) sum_all = sum_all * (LL) (k + 1) % mod;
	dp[0] = 1;
	for (int pl = n - 1; pl >= 0; --pl) {
		memcpy(odp, dp, sizeof dp);
		memset(dp, 0, sizeof dp);
		for (int val = 0; val <= k; ++val) {
			if (val > pl + 1) {
				for (int j = 0; j < N * N; ++j) if (odp[j]) sadd(dp[j], odp[j]);	
			} else {
				for (int j = 0; j < N * N; ++j)	if (odp[j]) {
					int fin_val = j + val;
					int add = fin_val / (pl + 1);
					sadd(dp[j + add], odp[j]);
				}
			}
		}
	}
	for (int j = 0; j < N * N; ++j) if (dp[j]) {
		sum_all = (sum_all - dp[j] * (LL) j % mod + mod) % mod;
	}
	cout << sum_all << endl;
}




