#include <bits/stdc++.h>
using namespace std;
const int N = 110;
const int INF = 0x3f3f3f3f;
const int iinf = 1 << 30;
const long long linf = 2e18;
const int MOD = 1000000007;
const double eps = 1e-7;
void douout(double x) { printf("%lf\n", x + 0.0000000001); }
template <class T>
void print(T a) {
  cout << a << endl;
  exit(0);
}
template <class T>
void chmin(T &a, T b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, T b) {
  if (a < b) a = b;
}
template <class T>
void add(T &a, T b) {
  a += b;
  if (a >= MOD) a -= MOD;
}
template <class T>
void sub(T &a, T b) {
  a = (a - b + MOD) % MOD;
}
template <class T>
void mul(T &a, T b) {
  a = (long long)a * b % MOD;
}
template <class T>
T read() {
  int f = 1;
  T x = 0;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m, ans, lst;
int f[N][4 * N];
signed main() {
  scanf("%d%d", &n, &m);
  ans = n * m * (m + 1) / 2;
  for (int i = (1); i <= (n - 1); i++) mul(ans, m + 1);
  f[n + 1][0] = 1;
  for (int i = n; i >= 1; lst += (lst + min(i, m)) / i, i--)
    for (int j = (0); j <= (lst); j++)
      for (int k = (0); k <= (m); k++)
        if (k <= i)
          add(f[i][j + (j + k) / i], f[i + 1][j]);
        else
          add(f[i][j], f[i + 1][j]);
  for (int i = (1); i <= (lst); i++)
    sub(ans, (int)((long long)f[1][i] * i % MOD));
  printf("%d\n", ans);
  return 0;
}
