#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define pdi pair<db,int>
#define mp make_pair
#define pb push_back
#define enter putchar('\n')
#define space putchar(' ')
#define eps 1e-8
#define mo 974711
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;char c = getchar();T f = 1;
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
bool vis[105][100005];
int sum[105][100005],cnt[105][100005];
int N,K;
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a * b % MOD;
}
void update(int &x,int y) {
    x = inc(x,y);
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
void dfs(int p,int d) {
    if(vis[p][d]) return;
    vis[p][d] = 1;
    if(p == 1) {
	cnt[p][d] = K + 1;sum[p][d] = (mul(2,MOD - d) + (K + 2) * (K - 1) / 2) % MOD;
	return ;
    }
    for(int i = 0 ; i < p ; ++i) {
	if(i > K) break;
	dfs(p - 1,d + (d + i) / p);
	update(cnt[p][d],cnt[p - 1][d + (d + i) / p]);
	update(sum[p][d],inc(sum[p - 1][d + (d + i) / p] ,mul(cnt[p - 1][d + (d + i) / p] ,inc(i, MOD - (d + i) / p))));
    }
    if(p <= K) {
	dfs(p - 1,d + 1 + d / p);
	update(cnt[p][d],cnt[p - 1][d + 1 + d / p]);
	update(sum[p][d],inc(sum[p - 1][d + 1 + d / p], mul(cnt[p - 1][d + 1 + d / p],inc(p, MOD - d / p - 1))));
    }
    for(int i = p + 1 ; i <= K ; ++i) {
	dfs(p - 1,d);
	update(cnt[p][d],cnt[p - 1][d]);
	update(sum[p][d],inc(sum[p - 1][d],mul(cnt[p - 1][d], i)));
    }
}
void Solve() {
    read(N);read(K);
    dfs(N,0);
    out(sum[N][0]);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}
