代码
#include<stdio.h>
#define P 1000000007
int fast(int a,int b){
int res=1;
while(b){
if(b&1)res=1LL*res*a%P;
b>>=1;
a=1LL*a*a%P;
}
return res;
}
int main(){
// freopen("sum.in","r",stdin);
// freopen("sum.out","w",stdout);
int n,m,ans=0;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++){
if(i==1)ans+=m;
int x=1LL*i*(fast(i,m)-1+P)%P;
ans=(ans+1LL*x*fast(i-1,P-2))%P;
}
printf("%d\n",ans%P);
return 0;
}