#include <bits/stdc++.h>
using namespace std;

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int mx = 0;
  vector<mint> dp(mx + 1, 0), way(mx + 1, 1);
  for (int i = n; i; --i) {
    mx += 1 + mx / i;
    vector<mint> ndp(mx + 1), nway(mx + 1);
    for (int j = 0; j < (int)dp.size(); ++j) {
      for (int x = 0; x <= m; ++x) {
        if (x <= i) {
          int nj = j + (x + j) / i;
          ndp[nj] += (x + j) / i * way[j] + dp[j];
          nway[nj] += way[j];
        } else {
          ndp[j] += dp[j];
          nway[j] += way[j];
        }
      }
    }
    swap(dp, ndp);
    swap(way, nway);
  }
  mint res = power(mint(m + 1), n) * n * m / 2 - accumulate(begin(dp), end(dp), mint(0));
  cout << res.v << '\n';
}

### Prompt

Create a solution in CPP for 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 <bits/stdc++.h>
using namespace std;

template <class T, class F = multiplies<T>>
T power(T a, long long n, F op = multiplies<T>(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long a = 0) : v((a %= M) < 0 ? a + M : a) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m r) { if ((v += r.v) >= M) v -= M; return *this; }
  m& operator-=(m r) { if (v < r.v) v += M; v -= r.v; return *this; }
  m& operator*=(m r) { v = (uint64_t)v * r.v % M; return *this; }
  m& operator/=(m r) { return *this *= power(r, M - 2); }
  friend m operator+(m l, m r) { return l += r; }
  friend m operator-(m l, m r) { return l -= r; }
  friend m operator*(m l, m r) { return l *= r; }
  friend m operator/(m l, m r) { return l /= r; }
  friend bool operator==(m l, m r) { return l.v == r.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 1e9 + 7;
using mint = modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int mx = 0;
  vector<mint> dp(mx + 1, 0), way(mx + 1, 1);
  for (int i = n; i; --i) {
    mx += 1 + mx / i;
    vector<mint> ndp(mx + 1), nway(mx + 1);
    for (int j = 0; j < (int)dp.size(); ++j) {
      for (int x = 0; x <= m; ++x) {
        if (x <= i) {
          int nj = j + (x + j) / i;
          ndp[nj] += (x + j) / i * way[j] + dp[j];
          nway[nj] += way[j];
        } else {
          ndp[j] += dp[j];
          nway[j] += way[j];
        }
      }
    }
    swap(dp, ndp);
    swap(way, nway);
  }
  mint res = power(mint(m + 1), n) * n * m / 2 - accumulate(begin(dp), end(dp), mint(0));
  cout << res.v << '\n';
}

```