#include #include #include #include #include #include #include #include #include #include #include #include #include #define INF 1000000000ll #define MOD 1000000007ll #define EPS 1e-10 #define REP(i,m) for(long long i=0; i P; typedef long double ld; ll _pow(ll a, ll n) { if(n==0) return 1; else { ll res = 1; ll buf = a; while(n>0) { if(n%2==1) { res *= buf; res %= MOD; } buf *= buf; buf %= MOD; n/=2; } return res; } } int main() { cin.tie(0); ios::sync_with_stdio(false); ll n,k; cin>>n>>k; n%=MOD; vector fac(10010); vector revfac(10010); ll buf=1; REP(i,10010) { if(i!=0) { buf*=i; buf%=MOD; } fac[i]=buf; revfac[i]=_pow(buf,MOD-2); } vector ber(10010,0); ber[0]=fac[10009]; FOR(i,1,10010) { REP(j,i) { if(j%2==i%2) ber[i]-=((fac[i+1]*revfac[i+1-j])%MOD*revfac[j])%MOD*ber[j]; else ber[i]+=((fac[i+1]*revfac[i+1-j])%MOD*revfac[j])%MOD*ber[j]; ber[i]%=MOD; } ber[i]*=_pow(i+1,MOD-2); ber[i]%=MOD; } ll ans=0; REP(i,k+1) { ans+=(((_pow(n,(k+1)-i)*fac[k+1])%MOD*revfac[k+1-i])%MOD*revfac[i])%MOD*ber[i]; ans%=MOD; } ans*=_pow(k+1,MOD-2); ans%=MOD; ans*=revfac[10009]; ans=(ans%MOD+MOD)%MOD; cout<