#include <bits/stdc++.h>

constexpr int N = 100, P = 1000000007;

int n, k;
int dp[N + 1][N * N + 1];

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    std::cin >> n >> k;
    
    dp[n][0] = 1;
    for (int i = n; i > 0; --i) {
        for (int j = 0; j <= n * n; ++j) {
            for (int v = 0; v <= k; ++v) {
                if (dp[i][j] == 0)
                    continue;
                int t = v <= i ? (v + j) / i : 0;
                dp[i - 1][j + t] = (dp[i - 1][j + t] + dp[i][j]) % P;
            }
        }
    }
    
    int ans = 0;
    for (int i = 0; i <= n * n; ++i)
        ans = (ans + 1ll * i * dp[0][i]) % P;
    int tot = 1ll * k * n * (P + 1) / 2 % P;
    for (int i = 0; i < n; ++i)
        tot = 1ll * tot * (k + 1) % P;
    ans = (tot - ans + P) % P;
    std::cout << ans << "\n";
    
    return 0;
}