#include <bits/stdc++.h>
using namespace std;
const int P = 2000;
int N, K;
pair<long long, long long> dp[110][P];
void add(pair<long long, long long> &a, long long ct, long long pf) {
  a = make_pair((a.first + ct) % 1000000007, (a.second + pf) % 1000000007);
}
int main() {
  scanf("%d%d", &N, &K);
  for (int i = 0; i <= N; ++i) {
    for (int j = 0; j < P; ++j) {
      dp[i][j] = make_pair(0LL, 0LL);
    }
  }
  dp[N][0] = make_pair(1LL, 0LL);
  for (int i = N; i >= 1; --i) {
    for (int j = 0; j < P; ++j) {
      if (dp[i][j] == make_pair(0LL, 0LL)) continue;
      for (int k = 0; k <= K; ++k) {
        if (k > i) {
          add(dp[i - 1][j], dp[i][j].first, dp[i][j].second);
        } else {
          int chg = k + j;
          int j2 = j + chg / i;
          add(dp[i - 1][j2], dp[i][j].first,
              dp[i][j].second + dp[i][j].first * chg);
        }
      }
    }
  }
  long long ret = 0;
  for (int i = 0; i < P; ++i) {
    ((ret) = ((ret) + (dp[0][i].first * i)) % 1000000007);
  }
  long long base = K * (K + 1) / 2;
  for (int i = 0; i < N - 1; ++i) base = base * (K + 1) % 1000000007;
  base = base * N % 1000000007;
  printf("%lld\n", (base + 1000000007 - ret) % 1000000007);
  return 0;
}
