#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

const ll MOD = 1000000007;
ll dp[101][10001];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N, K;
    cin >> N >> K;
    if(N == K) {
        dp[N][0] = N;
        dp[N][1] = 1;
    }else{
        dp[N][0] = K+1;
    }
    for(int i = N-1; i >= 1; i--){
        for(int j = N*K; j >= 0; j--){
            if(dp[i+1][j] > 0){
                for(int k = 0; k <= K; k++){
                    if(k < i){
                        dp[i][j+(k+j)/i] += dp[i+1][j];
                        dp[i][j+(k+j)/i] %= MOD;
                    }
                    if(k == i){
                        dp[i][1+j/i+j] += dp[i+1][j];
                        dp[i][1+j/i+j] %= MOD;
                    }
                    if(k > i){
                        dp[i][j] += dp[i+1][j];
                        dp[i][j] %= MOD;
                    }
                }
            }
        }
    }
    ll pow = 1;
    for(int i = 0; i < N-1; i++){
        pow *= (K+1);
        pow %= MOD;
    }
    ll sum = ((K*(K+1))/2)*N*pow;
    sum %= MOD;
    for(int j = N*K; j >= 0; j--){
        sum -= (ll)dp[1][j]*j;
        sum %= MOD;
        sum += MOD;
        sum %= MOD;
    }
    cout << sum << endl;
}