#include <bits/stdc++.h>

using namespace std;

const int Mod = 1e9 + 7, Nmax = 105;
typedef long long ll;

int dp[Nmax][Nmax*Nmax];
int N, K;


void add_to(int &x, int y)
{
    x += y;
    if(x >= Mod) x-=Mod;
        else if(x<0) x+=Mod;
}

int solve()
{
    int i, j;

    dp[0][0] = 1;

    for(i=1; i<=N; ++i)     /// lungime i, j eliminate
        for(j=0; j<=N*K; ++j)
        {
            int val = N - i + 1;
            int k;

            for(k=0; k<=K; ++k)
                if(k<=val)
                    add_to(dp[i][j+(k+j)/val], dp[i-1][j]);
                else
                    add_to(dp[i][j], dp[i-1][j]);
        }

    int ans = 0;
    for(i=0; i<=N*K; ++i)
        add_to(ans, (ll) dp[N][i] * i % Mod);
    return ans;
}

int main()
{
 //   freopen("input", "r", stdin);
    cin.sync_with_stdio(false); cin.tie(0);

    cin >> N >> K;

    int ans0 = (ll) K * (K+1) / 2 % Mod;
    int i;

    ans0 = (ll) N * ans0 % Mod;
    for(i=1; i<N; ++i) ans0 = (ll) ans0 * (K+1) % Mod;

    int ans = solve();

    ans = (ans0 - ans + Mod) % Mod;
    cout << ans << '\n';

    return 0;
}
