#include #define rep(i, n) for (int i = 0; i < (n); i++) #define repr(i, n) for (int i = (n) - 1; i >= 0; i--) using namespace std; using ll = long long; const int MOD = 1000000007; struct mint { int n; mint(int n_ = 0) : n(n_) {} }; mint operator-(mint a) { return -a.n + MOD * (a.n != 0); } mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; } mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; } mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; } mint &operator+=(mint &a, mint b) { return a = a + b; } mint &operator-=(mint &a, mint b) { return a = a - b; } mint &operator*=(mint &a, mint b) { return a = a * b; } istream &operator>>(istream &i, mint &a) { return i >> a.n; } ostream &operator<<(ostream &o, mint a) { return o << a.n; } mint dp0[305][305]; mint dp1[305][305]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int N, K; cin >> N >> K; if (N == 1) { cout << 0 << '\n'; return 0; } for (int i = 0; i <= K-1; i++) { dp0[i][i+1]=1; } rep(i, K) { memset(dp1, 0, sizeof(dp1)); rep(j, K+1) rep(k, K+1) { if (dp0[j][k].n == 0) continue; dp1[max(0,j-1)][k] += dp0[j][k]; if (j < k-1) dp1[j][k-1] += dp0[j][k]; dp1[j][k] += dp0[j][k]*(N-2); } swap(dp0, dp1); } mint ans = 0; for (int i = 1; i <= N; i++) { if (i + K <= N) { ans += i * dp0[0][1]; } else { int x = N - i + 1; for (int j = 0; j < K-x+1; j++) { ans += i * dp0[j][K-x+1]; } } } cout << ans << '\n'; }