#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;
}

### Prompt

Develop a solution in cpp to the problem described below:

Consider the following game:

* The game is played using a row of N squares and many stones.
* First, a_i stones are put in Square i\ (1 \leq i \leq N).
* A player can perform the following operation as many time as desired: "Select an integer i such that Square i contains exactly i stones. Remove all the stones from Square i, and add one stone to each of the i-1 squares from Square 1 to Square i-1."
* The final score of the player is the total number of the stones remaining in the squares.



For a sequence a of length N, let f(a) be the minimum score that can be obtained when the game is played on a.

Find the sum of f(a) over all sequences a of length N where each element is between 0 and K (inclusive). Since it can be extremely large, find the answer modulo 1000000007 (= 10^9+7).

Constraints

* 1 \leq N \leq 100
* 1 \leq K \leq N

Input

Input is given from Standard Input in the following format:


N K


Output

Print the sum of f(a) modulo 1000000007 (= 10^9+7).

Examples

Input

2 2


Output

10


Input

20 17


Output

983853488

### Response

```cpp
#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;
}

```