#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

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

int n, k;
int d[101][10001];

inline void modAdd(int &x, int y) {
    x += y;
    if (x >= MOD) {
        x -= MOD;
    }
}

int main() {
    cin >> n >> k;
    d[n][0] = 1;
    for (int i = n; i > 0; --i) {
        forn(j, n * k + 1) if (d[i][j]) {
            modAdd(d[i - 1][j], (LL)d[i][j] * max(0, k - i) % MOD);
            forn(p, min(k, i) + 1) {
                int cnt = (p + j) / i;
                modAdd(d[i - 1][j + cnt], d[i][j]);
            }
        }
    }
    int ans = (LL)k * (k + 1) / 2 % MOD * n % MOD;
    forn(i, n - 1) ans = (LL)ans * (k + 1) % MOD;
    forn(i, n * k + 1) ans = (ans - (LL)d[0][i] * i) % MOD;
    if (ans < 0) ans += MOD;
    cout << ans << endl;
    return 0;
}
