[egin{aligned}
ans&=sumlimits_{i=1}^n{nchoose i}i^k\
&=sumlimits_{i=1}^nfrac{n!}{i!(n-i)!}sumlimits_{j=1}^{min(i,k)}left{katop j
ight}i^{underline j}\
&=sumlimits_{i=1}^nsumlimits_{j=1}^{min(i,k)}left{katop j
ight}frac{n!}{(n-i)!(i-j)!}\
&=sumlimits_{i=1}^{min(n,k)}left{katop i
ight}sumlimits_{j=i}^nfrac{n!}{(n-j)!(j-i)!}\
&=sumlimits_{i=1}^{min(n,k)}left{katop i
ight}frac{n!}{(n-i)!}sumlimits_{j=i}^n{n-ichoose n-j}\
&=sumlimits_{i=1}^{min(n,k)}left{katop i
ight}frac{n!}{(n-i)!}2^{n-i}
end{aligned}
]
#include<cstdio>
const int N=5001,P=1000000007;
int S[N][N];
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int mul(int a,int b){return 1ll*a*b%P;}
int pow(int a,int k){int r=1;for(;k;k>>=1,a=mul(a,a))if(k&1)r=mul(a,r);return r;}
int main()
{
int n,k,ans=0;scanf("%d%d",&n,&k),S[0][0]=1;
for(int i=1;i<=k;++i) for(int j=1;j<=i;++j) inc(S[i][j]=S[i-1][j-1],mul(j,S[i-1][j]));
for(int i=1,t=n;i<=k&&i<=n;++i) inc(ans,1ll*S[k][i]*t%P*pow(2,n-i)%P),t=mul(t,n-i);
printf("%d",ans);
}