/**
 *    author:  tourist
 *    created: 25.11.2017 13:17:25       
**/
#include <bits/stdc++.h>

using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int md = (int) 1e9 + 7;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) a -= md;
}

inline void sub(int &a, int b) {
  a -= b;
  if (a < 0) a += md;
}

inline int mul(int a, int b) {
#if !defined(_WIN32) || defined(_WIN64)
  return (int) ((long long) a * b % md);
#endif
  unsigned long long x = (long long) a * b;
  unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
  asm(
    "divl %4; \n\t"
    : "=a" (d), "=d" (m)
    : "d" (xh), "a" (xl), "r" (md)
  );
  return m;
}

inline int power(int a, long long b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int a) {
  a %= md;
  if (a < 0) a += md;
  int b = md, u = 0, v = 1;
  while (a) {
    int t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}

const int N = 111;

int f[N][N * N];

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  int total = mul(power(k + 1, n), mul(n * k, inv(2)));
  f[n][0] = 1;
  for (int i = n; i >= 1; i--) {
    for (int j = 0; j < N * N; j++) {
      int ft = f[i][j];
      if (ft == 0) {
        continue;
      }
      debug(i, j, ft);
      for (int at = 0; at <= k; at++) {
        int nj = j;
        if (at <= i) {
          int to_next = i - at;
          int have = j;
          if (have >= to_next) {
            nj++;
            have -= to_next;
            nj += have / i;
          }
        }
        add(f[i - 1][nj], ft);
      }
    }
  }
  for (int j = 0; j < N * N; j++) {
    if (f[0][j] > 0) {
      debug(0, j, f[0][j]);
    }
    sub(total, mul(j, f[0][j]));
  }
  printf("%d\n", total);
  return 0;
}
