#include <bits/stdc++.h>
using namespace std;
long long n, k, dp[110][110][2010], sum[110][2010];
signed main() {
  cin >> n >> k;
  long long p = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 0; j <= k; j++) {
      for (long long l = 0; l <= n * 10; l++) {
        if (j > i) {
          dp[i][j][l] = sum[i - 1][l] + (((l + j) * p) % 1000000007);
          dp[i][j][l] %= 1000000007;
        } else {
          long long val = j + l;
          long long num = val / i, rem = val % i;
          dp[i][j][l] = sum[i - 1][l + num] + ((rem * p) % 1000000007);
          dp[i][j][l] %= 1000000007;
        }
      }
      for (long long l = 0; l <= n * 15; l++) {
        sum[i][l] += dp[i][j][l];
        sum[i][l] %= 1000000007;
      }
    }
    p *= (k + 1);
    p %= 1000000007;
  }
  cout << sum[n][0] << endl;
  return 0;
}
