#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:2
*Problem:Mancala
*Date:2019-7-3
*Algorithm:Monkey King's Formula
*Stats:Unknown*/

bool debug=false;

int table[]={0,0,10,218,4224,86824,1952672,48334090,313331137,979800274,828540260,695210844,345903227,725536399,533377947,126870238,417392240,582344565,570144113,387531847,95472904,736367570,100824653,53789760,861980712,126607859,241069168,159577844,127999019,739565197,588572026,
			 472004108,198573042,281307947,286342614,686185824,48747915,30658266,198584024,760183454,258844241,646193002,972078799,897190473,283365309,488780441,951115850,28681383,942905856,688391542,525884844,41980196,386470834,476933350,752854574,920579153,963866760,52440366,648227423,224231848,133288127,
			 149349410,239142404,803678704,197142159,350958507,502820237,752727832,871386865,338082736,566806799,174435924,823030120,175675710,613983717,27947594,438064939,461569938,546560028,895202927,431746632,443078512,972753815,617930628,367826740,539142587,514039930,351945083,68959273,870822947,125889175,
			 452006881,101355703,195535277,755580870,603125858,943472898,483436448,536722284,883521289,900100930
			 };

int n,k;

ll dp[105][105];

const ll mod=1e9+7;

ll qp(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll ans=qp(a,b/2);
	if(b%2){
		return ans*ans%mod*a%mod;
	}else{
		return ans*ans%mod;
	}
}

ll S(int n,int k){
	if(n==k){
		return table[n];
	}
	
	if(dp[n][k]!=-1){
		return dp[n][k];
	}
	
	ll ans=0;
	for(int i=0;i<=k;i++){
		ans+=(S(n-1,k)+qp(k+1,n-1)*i%mod)%mod;
		ans%=mod;
	}
	
	return dp[n][k]=ans;
}
int main(int argc,char* argv[]){
	memset(dp,-1,sizeof(dp));
	
	cin>>n>>k;
	cout<<S(n,k)<<endl;
	return 0;
}


### Prompt

Create a solution in cpp for the following problem:

Consider the following game:

* The game is played using a row of N squares and many stones.
* First, a_i stones are put in Square i\ (1 \leq i \leq N).
* A player can perform the following operation as many time as desired: "Select an integer i such that Square i contains exactly i stones. Remove all the stones from Square i, and add one stone to each of the i-1 squares from Square 1 to Square i-1."
* The final score of the player is the total number of the stones remaining in the squares.



For a sequence a of length N, let f(a) be the minimum score that can be obtained when the game is played on a.

Find the sum of f(a) over all sequences a of length N where each element is between 0 and K (inclusive). Since it can be extremely large, find the answer modulo 1000000007 (= 10^9+7).

Constraints

* 1 \leq N \leq 100
* 1 \leq K \leq N

Input

Input is given from Standard Input in the following format:


N K


Output

Print the sum of f(a) modulo 1000000007 (= 10^9+7).

Examples

Input

2 2


Output

10


Input

20 17


Output

983853488

### Response

```cpp
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pii pair<int,int>
#define qi ios::sync_with_stdio(0)
/**==Info==
*Program:2
*Problem:Mancala
*Date:2019-7-3
*Algorithm:Monkey King's Formula
*Stats:Unknown*/

bool debug=false;

int table[]={0,0,10,218,4224,86824,1952672,48334090,313331137,979800274,828540260,695210844,345903227,725536399,533377947,126870238,417392240,582344565,570144113,387531847,95472904,736367570,100824653,53789760,861980712,126607859,241069168,159577844,127999019,739565197,588572026,
			 472004108,198573042,281307947,286342614,686185824,48747915,30658266,198584024,760183454,258844241,646193002,972078799,897190473,283365309,488780441,951115850,28681383,942905856,688391542,525884844,41980196,386470834,476933350,752854574,920579153,963866760,52440366,648227423,224231848,133288127,
			 149349410,239142404,803678704,197142159,350958507,502820237,752727832,871386865,338082736,566806799,174435924,823030120,175675710,613983717,27947594,438064939,461569938,546560028,895202927,431746632,443078512,972753815,617930628,367826740,539142587,514039930,351945083,68959273,870822947,125889175,
			 452006881,101355703,195535277,755580870,603125858,943472898,483436448,536722284,883521289,900100930
			 };

int n,k;

ll dp[105][105];

const ll mod=1e9+7;

ll qp(ll a,ll b){
	if(b==0){
		return 1;
	}
	ll ans=qp(a,b/2);
	if(b%2){
		return ans*ans%mod*a%mod;
	}else{
		return ans*ans%mod;
	}
}

ll S(int n,int k){
	if(n==k){
		return table[n];
	}
	
	if(dp[n][k]!=-1){
		return dp[n][k];
	}
	
	ll ans=0;
	for(int i=0;i<=k;i++){
		ans+=(S(n-1,k)+qp(k+1,n-1)*i%mod)%mod;
		ans%=mod;
	}
	
	return dp[n][k]=ans;
}
int main(int argc,char* argv[]){
	memset(dp,-1,sizeof(dp));
	
	cin>>n>>k;
	cout<<S(n,k)<<endl;
	return 0;
}


```