#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1000000007;

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll dp[101][5000];

ll naive(ll n, ll k){
    ll ret = 0;
    REP(x,powll(k+1,n)){
        VI a(n);
        ll tmp = x;
        REP(i,n){
            a[i] = tmp % (k+1);
            tmp /= k+1;
        }
        while (1){
            bool found = false;
            REP(i,n){
                if (a[i] == i+1){
                    a[i] = 0;
                    REP(j,i) a[j]++;
                    found = true;
                    break;
                }
            }
            if (!found) break;
        }
        REP(i,n) ret += a[i];
    }
    return ret;
}

int main() {
    ll n, k;
    cin >> n >> k;

    ll all = k * n;
    REP(i,n) all = (all * (k+1)) % mod;
    all = divll(all, 2);

    dp[n][0] = 1;
    FORR(i,n,1){
        REP(j,5000){
            if (dp[i][j] == 0) continue;
            REP(x,k+1){
                if (x > i) dp[i-1][j] = (dp[i-1][j] + dp[i][j]) % mod;
                else dp[i-1][j+(j+x)/i] = (dp[i-1][j+(j+x)/i] + dp[i][j]) % mod;
            }
        }
    }

    ll ans = all;
    REP(j,5000) ans = (ans - j * dp[0][j] + 50000 * mod) % mod;

    // cout << all << endl;

    // REP(i,n+1){
    //     REP(j,10) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << ans << endl;

    // cout << naive(n,k) << endl;
    return 0;
}



### Prompt

Please formulate a cpp solution to the following problem:

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 <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

const ll mod = 1000000007;

ll add(ll x, ll y){
    return (x+y)%mod;
}

ll mul(ll x, ll y){
    return (x%mod)*(y%mod)%mod;
}

ll powll(ll x, ll y){
    x %= mod;
    ll res = 1LL;
    while(y){
        if (y & 1LL)
            res *= x;
        res %= mod;
        x = (x*x) % mod;
        y >>= 1LL;
    }
    return res;
}

ll divll(ll x, ll y){
    x %= mod;
    return (x * powll(y,mod-2)) % mod;
}

ll dp[101][5000];

ll naive(ll n, ll k){
    ll ret = 0;
    REP(x,powll(k+1,n)){
        VI a(n);
        ll tmp = x;
        REP(i,n){
            a[i] = tmp % (k+1);
            tmp /= k+1;
        }
        while (1){
            bool found = false;
            REP(i,n){
                if (a[i] == i+1){
                    a[i] = 0;
                    REP(j,i) a[j]++;
                    found = true;
                    break;
                }
            }
            if (!found) break;
        }
        REP(i,n) ret += a[i];
    }
    return ret;
}

int main() {
    ll n, k;
    cin >> n >> k;

    ll all = k * n;
    REP(i,n) all = (all * (k+1)) % mod;
    all = divll(all, 2);

    dp[n][0] = 1;
    FORR(i,n,1){
        REP(j,5000){
            if (dp[i][j] == 0) continue;
            REP(x,k+1){
                if (x > i) dp[i-1][j] = (dp[i-1][j] + dp[i][j]) % mod;
                else dp[i-1][j+(j+x)/i] = (dp[i-1][j+(j+x)/i] + dp[i][j]) % mod;
            }
        }
    }

    ll ans = all;
    REP(j,5000) ans = (ans - j * dp[0][j] + 50000 * mod) % mod;

    // cout << all << endl;

    // REP(i,n+1){
    //     REP(j,10) cout << dp[i][j] << " ";
    //     cout << endl;
    // }

    cout << ans << endl;

    // cout << naive(n,k) << endl;
    return 0;
}



```