#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<lint, lint> pi;
const int MAXN = 200005;
const int mod = 1e9 + 7;

int n, k;
bool vis[105][10005];
pi dp[105][10005];

int mx = 0;
pi f(int cur, int exp){
	mx = max(mx, exp);
	if(cur == 0) return pi(0, 1);
	if(vis[cur][exp]) return dp[cur][exp];
	pi ans(0, 0);
	for(int i=0; i<=k; i++){
		if(i > cur){
			auto x = f(cur - 1, exp);
			ans.first += x.first + x.second * (i + exp) % mod;
			ans.second += x.second;
		}
		else{
			auto x = f(cur - 1, exp + (exp + i) / cur);
			ans.first += x.first + x.second * ((exp + i) % cur);
			ans.second += x.second;
		}
	}
	ans.first %= mod;
	ans.second %= mod;
	vis[cur][exp] = 1;
	return dp[cur][exp] = ans;
}

int main(){
	cin >> n >> k;
	cout << f(n, 0).first<< endl;
}
