#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int MOD = 1000000007;
inline long long mod(long long a, long long m) { return (a % m + m) % m; }

struct Fp {
    long long val;
    
    Fp() : val(0) {}
    Fp(long long val_) { this->val = mod(val_, MOD); }
    Fp operator = (long long val_) { this->val = mod(val_, MOD); return *this; }
    inline Fp operator - () { return mod(-val, MOD); }
    inline const Fp& operator += (const Fp &x);
    inline const Fp& operator -= (const Fp &x);
    inline const Fp& operator *= (const Fp &x);
    inline const Fp& operator /= (const Fp &x);
};

ostream &operator << (ostream &os, Fp x) { return os << x.val;}
istream &operator >> (istream &is, Fp &x) { is >> x; return is; }
bool operator == (Fp x, Fp y) { return mod(x.val, MOD) == mod(y.val, MOD); }

inline Fp operator + (Fp x, Fp y) { return mod(x.val + y.val, MOD); }
inline Fp operator - (Fp x, Fp y) { return mod(x.val - y.val, MOD); }
inline Fp operator * (Fp x, Fp y) { return mod(x.val * y.val, MOD); }
inline Fp operator / (Fp x, Fp y) {
    long long a = y.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    return x * u;
}
inline Fp fpow(Fp a, long long n) {
    if (n == 0) return Fp(1);
    Fp t = fpow(a, n/2);
    t = t * t; if (n & 1) t = t * a;
    return t;
}
inline const Fp& Fp::operator += (const Fp &x) {*this = *this + x; return *this;}
inline const Fp& Fp::operator -= (const Fp &x) {*this = *this - x; return *this;}
inline const Fp& Fp::operator *= (const Fp &x) {*this = *this * x; return *this;}
inline const Fp& Fp::operator /= (const Fp &x) {*this = *this / x; return *this;}


long long N, K;

Fp dp[101][10100];
Fp solve() {
    Fp all = fpow(Fp(K)+1, N-1) * K * (K+1) / 2 * N;
    
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j < 10000; ++j) {
            if (dp[i][j] == 0) continue;
            //cout << i << ", " << j << ": " << dp[i][j] << endl;
            
            if (i == N) continue;
            for (int k = 0; k <= K; ++k) {
                if (k > N-i) dp[i+1][j] += dp[i][j];
                else dp[i+1][j + (k+j)/(N-i)] += dp[i][j];
            }
        }
    }
    
    Fp con = 0;
    for (int j = 0; j < 10000; ++j) {
        con += dp[N][j] * j;
    }

    //COUT(all); COUT(con);
    
    return all - con;
}

int main () {
    while (cin >> N >> K) {
        cout << solve() << endl;
    }
}






















### Prompt

Your challenge is to write 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 <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

const int MOD = 1000000007;
inline long long mod(long long a, long long m) { return (a % m + m) % m; }

struct Fp {
    long long val;
    
    Fp() : val(0) {}
    Fp(long long val_) { this->val = mod(val_, MOD); }
    Fp operator = (long long val_) { this->val = mod(val_, MOD); return *this; }
    inline Fp operator - () { return mod(-val, MOD); }
    inline const Fp& operator += (const Fp &x);
    inline const Fp& operator -= (const Fp &x);
    inline const Fp& operator *= (const Fp &x);
    inline const Fp& operator /= (const Fp &x);
};

ostream &operator << (ostream &os, Fp x) { return os << x.val;}
istream &operator >> (istream &is, Fp &x) { is >> x; return is; }
bool operator == (Fp x, Fp y) { return mod(x.val, MOD) == mod(y.val, MOD); }

inline Fp operator + (Fp x, Fp y) { return mod(x.val + y.val, MOD); }
inline Fp operator - (Fp x, Fp y) { return mod(x.val - y.val, MOD); }
inline Fp operator * (Fp x, Fp y) { return mod(x.val * y.val, MOD); }
inline Fp operator / (Fp x, Fp y) {
    long long a = y.val, b = MOD, u = 1, v = 0;
    while (b) {
        long long t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    return x * u;
}
inline Fp fpow(Fp a, long long n) {
    if (n == 0) return Fp(1);
    Fp t = fpow(a, n/2);
    t = t * t; if (n & 1) t = t * a;
    return t;
}
inline const Fp& Fp::operator += (const Fp &x) {*this = *this + x; return *this;}
inline const Fp& Fp::operator -= (const Fp &x) {*this = *this - x; return *this;}
inline const Fp& Fp::operator *= (const Fp &x) {*this = *this * x; return *this;}
inline const Fp& Fp::operator /= (const Fp &x) {*this = *this / x; return *this;}


long long N, K;

Fp dp[101][10100];
Fp solve() {
    Fp all = fpow(Fp(K)+1, N-1) * K * (K+1) / 2 * N;
    
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j < 10000; ++j) {
            if (dp[i][j] == 0) continue;
            //cout << i << ", " << j << ": " << dp[i][j] << endl;
            
            if (i == N) continue;
            for (int k = 0; k <= K; ++k) {
                if (k > N-i) dp[i+1][j] += dp[i][j];
                else dp[i+1][j + (k+j)/(N-i)] += dp[i][j];
            }
        }
    }
    
    Fp con = 0;
    for (int j = 0; j < 10000; ++j) {
        con += dp[N][j] * j;
    }

    //COUT(all); COUT(con);
    
    return all - con;
}

int main () {
    while (cin >> N >> K) {
        cout << solve() << endl;
    }
}






















```