#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 int INF = 1e9;
inline int read(){
	int 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 long long mod=1000000007ll;
void ad(long long &a,long long b){a+=b;a%=mod;}
void mn(long long &a,long long b){a+=mod-b;a%=mod;}
void ml(long long &a,long long b){a*=b;a%=mod;}
ll P[205];
ll dp[10005][205];
int main()
{
	int n,k;
	cin>>n>>k;
	P[0]=1ll;
	for(int i=0;i<=n;i++)
	{
		P[i+1]=P[i]*(k+1)%mod;
	}
	ll ans=0ll;
	dp[0][n]=1;
	for(int i=n-1;i>=0;i--)
	{
		for(int y=0;y<=n*n;y++)
		{
			if(!dp[y][i+1])
			{
				continue;
			}
			for(int x=0;x<=k;x++)
			{
				if(x<=i+1 and i+1-x<=y)
				{
					int p=(x+y)/(i+1);
					ad(ans,P[i]*p%mod*dp[y][i+1]%mod);
					ad(dp[y+p][i],dp[y][i+1]);
				}
				else
				{
					ad(dp[y][i],dp[y][i+1]);
				}
			}
		}
	}
	cout<<(k*(k+1)/2*P[n-1]%mod*n%mod+mod-ans)%mod;
	return 0;
}
 