#include <bits/stdc++.h>
#pragma GCC optimize(1)
#pragma G++ optimize(1)
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#pragma GCC optimize(3)
#pragma G++ optimize(3)
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
using namespace std;
inline void rdl(long long &val) {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  val = x * f;
}
inline void rdi(int &val) {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  val = x * f;
}
inline long long rdl() {
  long long x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline int rdi() {
  int x = 0;
  int f = 1;
  char ch = getchar();
  while ((ch < '0' or ch > '9') and ch != '-') ch = getchar();
  if (ch == '-') {
    f = -1;
    ch = getchar();
  }
  while (ch >= '0' and ch <= '9') {
    x = (x << 3) + (x << 1) + ch - '0';
    ch = getchar();
  }
  return x * f;
}
inline void write(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(int x) {
  write(x);
  putchar(' ');
}
inline void print(int x) {
  write(x);
  putchar('\n');
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void _write(long long x) {
  write(x);
  putchar(' ');
}
inline void print(long long x) {
  write(x);
  putchar('\n');
}
pair<long long, long long> dp[111][4444];
int n, k;
const long long md = 1000000007;
inline void addpair(pair<long long, long long> &a,
                    pair<long long, long long> p) {
  a.first += p.first;
  a.second += p.second;
  if (a.first >= md) a.first -= md;
  if (a.second >= md) a.second -= md;
}
inline void add(long long &x, long long y) {
  x += y;
  if (x >= md) x -= md;
}
inline long long qp(long long a, long long b) {
  long long rt = 1;
  while (b) {
    if (b & 1) rt = (rt * a) % md;
    a = (a * a) % md;
    b >>= 1;
  }
  return rt;
}
int main() {
  rdi(n), rdi(k);
  int i, j, f;
  dp[n][0] = make_pair(1ll, 0ll);
  for (i = n; i; --i) {
    for (j = 0; j < 4000; ++j) {
      if (dp[i][j] == make_pair(0ll, 0ll)) continue;
      for (f = 0; f <= k; ++f) {
        if (f > i) {
          addpair(dp[i - 1][j], dp[i][j]);
        } else {
          long long cg = f + j, tj = j + cg / i;
          addpair(
              dp[i - 1][tj],
              make_pair(dp[i][j].first, dp[i][j].second + dp[i][j].first * cg));
        }
      }
    }
  }
  long long ans = 0;
  for (i = 0; i < 4000; ++i) add(ans, dp[0][i].first * i);
  long long base = k;
  base = (base * qp(k + 1, n)) % md * n % md * 500000004ll % md;
  print((base + md - ans) % md);
}
