#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
int pw(int x, int y) {
  int res = 1;
  while (y) {
    if (y & 1) res = (long long)res * x % MOD;
    x = (long long)x * x % MOD;
    y >>= 1;
  }
  return res;
}
int N, K;
int D[110][10010];
void solve() {
  scanf("%d%d", &N, &K);
  long long ans = K * (K + 1) / 2;
  ans = ans * pw(K + 1, N - 1) % MOD;
  ans = ans * N % MOD;
  D[N + 1][0] = 1;
  for (int i = N; i; i--) {
    for (int j = -i; j <= K - i; j++) {
      for (int k = 0; k <= N * K; k++) {
        int nk = k;
        if (j <= 0 && -j <= k) {
          nk = (k + (k + j) / i + 1);
          ans = (ans -
                 pw(K + 1, i - 1) * (long long)D[i + 1][k] % MOD * (nk - k)) %
                MOD;
          if (ans < 0) ans += MOD;
        }
        D[i][nk] = (D[i][nk] + D[i + 1][k]) % MOD;
      }
    }
  }
  printf("%lld\n", ans);
}
int main() {
  int Tc = 1;
  for (int tc = 1; tc <= Tc; tc++) {
    solve();
  }
  return 0;
}
