#include #include #include using namespace std; #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() template bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;} template bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;} using ll=unsigned long long; const ll MOD=1e9+7; const int MAX=2e4+10; vectorfac(MAX),finv(MAX),inv(MAX); void set_fac(){ fac[0]=fac[1]=1; finv[0]=finv[1]=1; inv[1]=1; for (int i=2;i>i&1){ re=(re*k)%MOD; } k=k*k%MOD; } return re; } ll modinv(ll x){ return power(x, MOD-2); } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); set_fac(); ll N; int K; cin>>N>>K; vectordp(K+1); dp[0]=N%MOD; ll P=(N+1)%MOD; for(int i=1;i<=K;i++){ P*=(N+1)%MOD; P%=MOD; dp[i]=P-1; for(int j=2;j<=i+1;j++){ dp[i]+=MOD-cmb(i+1,j)*dp[i+1-j]%MOD; dp[i]%=MOD; } dp[i]*=inv[i+1]; dp[i]%=MOD; } cout<