//#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef long double ld;
#define migmig ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define F first
#define S second
#define SZ(x) ll((x).size())
#define all(x) (x).begin(), (x).end()
#define deb(x) cerr << #x << " = " << x << '\n'
#define dokme(x) { cout << x << endl; return 0; }
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxn = 1e5 + 10;
const int inf = 1e9;
const int LOG = 30;
const int mod = 1e9 + 7;
const int sq = 450;
#define mid ((l + r) / 2)
#define lc (id * 2)
#define rc (lc + 1)
ll pw(ll a, ll b) {
ll res = 1;
while (b) {
if (b & 1) {
(res *= a) %= mod;
}
b /= 2;
(a *= a) %= mod;
}
return res;
}
int n, k, f[maxn], iv[maxn];
void perp() {
f[0] = 1;
for (int i = 1; i < maxn; i++)
f[i] = (f[i - 1] * i) % mod;
iv[maxn - 1] = pw(f[maxn - 1], mod - 2);
for (int i = maxn - 2; i >= 0; i--)
iv[i] = (iv[i + 1] * (i + 1)) % mod;
}
ll C(ll a, ll b) {
if (a < 0 || b < 0 || b > a)
return 0;
return f[a] * iv[b] % mod * iv[a - b] % mod;
}
signed main() {
migmig;
perp();
cin >> n >> k;
ll ans = 0;
// deb(C(2, 1));
for (int i = 0; i < k; i++) {
(ans += C(n + i, i) * pw(k - i, n) % mod * (i & 1 ? mod - 1 : 1)) %= mod;
}
cout << ans << '\n';
}