#include <bits/stdc++.h>
using namespace std;
using namespace std;
const int SIZE = 105;
const long long p = 7 + 1e9;
const long long INF = 1LL << 60;
long long DP[SIZE][SIZE * SIZE * 2], H[SIZE], P[SIZE];
long long N, K;
long long power(long long n, long long r) {
  if (r == 0) return 1;
  if (r == 1) return n;
  long long ans = power(n, r / 2);
  return ans * ans % p * power(n, r % 2) % p;
}
long long als(long long n, long long k) {
  long long pls = k * (k + 1) / 2 % p * power(k + 1, n - 1) % p * n % p;
}
long long solve() {
  long long ans = 0;
  cin >> N >> K;
  DP[N][0] = 1;
  for (long long i = (0); i < (int)(N); i++) {
    long long now = N - i;
    long long times = 0;
    for (long long j = (0); j < (int)(SIZE * SIZE); j++) {
      for (long long k = (0); k < (int)(K + 1); k++) {
        times = 0;
        if (now >= k) {
          times = (j + k) / now;
        }
        DP[now - 1][j + times] += DP[now][j] % p;
      }
    }
  }
  for (long long i = (0); i < (int)(SIZE * SIZE); i++) {
    ans += i * DP[0][i];
    ans %= p;
  }
  ans %= p;
  return (als(N, K) + p - ans) % p;
}
int main() {
  cout << solve() << endl;
  return 0;
}
