#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const ll INF = 1e9;
inline ll read(){
	ll X = 0,w = 0 ;
	char ch = 0;
	while(!isdigit(ch)) {w |= ch == '-';ch = getchar();}
	while(isdigit(ch)) X = (X<<3) + (X<<1) + (ch ^ 48),ch = getchar();
	return w ? -X : X;
}
const ll mod=1e9+7;
void add(ll &a,ll b)
{
	a+=b;
	a%=mod;
}
ll P[205];
ll dp[10005][205];
int main()
{
	ll n,k;
	cin>>n>>k;
	P[0]=1;
	for(ll i=0;i<=n;i++)
	{
		P[i+1]=P[i]*(k+1)%mod;
	}
	ll ans=0;
	dp[0][n]=1;
	for(ll i=n-1;i>=0;i--)
	{
		for(ll y=0;y<=n*n;y++)
		{
			if(!dp[y][i+1])
			{
				continue;
			}
			for(ll x=0;x<=k;x++)
			{
				if(x<=i+1 and i-x+1<=y)
				{
					ll p=(x+y)/(i+1);
					add(ans,P[i]*p%mod*dp[y][i+1]%mod);
					add(dp[y+p][i],dp[y][i+1]);
				}
				else
				{
					add(dp[y][i],dp[y][i+1]);
				}
			}
		}
	}
	cout<<(k*(k+1)/2*P[n-1]%mod*n%mod+mod-ans)%mod;
	return 0;
}