#include using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int N,K; ll from[302][302]; ll to[302][302]; ll mo=1000000007; ll ret; void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>K; for(i=1;i<=min(N,K);i++) from[i-1][i]++; FOR(i,K) { ZERO(to); for(x=0;x<=K;x++) for(y=x+1;y<=K;y++) { if(x==0) { // take y if(y-1>x) (to[x][y-1]+=from[x][y])%=mo; // other (to[x][y]+=from[x][y]*(N-1))%=mo; } else { // take x; (to[x-1][y]+=from[x][y])%=mo; // take y if(y-1>x) (to[x][y-1]+=from[x][y])%=mo; // other (to[x][y]+=from[x][y]*(N-2))%=mo; } } swap(from,to); } for(x=0;x<=K;x++) for(y=x+1;y<=K;y++) (ret+=y*from[x][y])%=mo; ZERO(from); from[K][K+1]=1; FOR(i,K) { ZERO(to); for(x=1;x<=K;x++) for(y=x+1;y<=K+1;y++) { // take x; (to[x-1][y]+=from[x][y])%=mo; // take y if(y-1>x) (to[x][y-1]+=from[x][y])%=mo; // other (to[x][y]+=from[x][y]*(N-2))%=mo; } swap(from,to); } for(y=1;y<=K+1;y++) { ll pat=0; for(x=0;x