#include <bits/stdc++.h>
using namespace std;
long long n, k, dp[110][110][1100], sum[110][1100];
signed main() {
  ios::sync_with_stdio(false);
  cin >> n >> k;
  for (long long j = 0; j <= k; j++) {
    for (long long l = 0; l <= n * 10; l++) {
      if (j > 1) {
        dp[1][j][l] = j + l;
      } else {
        dp[1][j][l] = 0;
      }
    }
    for (long long l = 0; l <= n * 10; l++) {
      sum[1][l] += dp[1][j][l];
      sum[1][l] %= 1000000007;
    }
  }
  long long p = 1;
  for (long long i = 2; i <= n; i++) {
    p *= (k + 1);
    p %= 1000000007;
    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;
          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;
          dp[i][j][l] %= 1000000007;
        }
      }
      for (long long l = 0; l <= n * 10; l++) {
        sum[i][l] += dp[i][j][l];
        sum[i][l] %= 1000000007;
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i <= k; i++) {
    ans += dp[n][i][0];
    ans %= 1000000007;
  }
  cout << ans << endl;
  return 0;
}
