#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
	return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
	if(!x){putchar('0');return;}
	int top=0;
	while(x)stack[++top]=x%10,x/=10;
	while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
const int mod=1e9+7;
inline int ad(int x){return x>=mod?x-mod:x;}
int f[5010][5010];
int main()
{
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),m=read();
	for(int i=1;i<=m;i++)f[0][i]=1;
	for(int i=1;i<=n;i++)
	{
		int ul=0;
		for(int j=1;j<=m;j++)
		{
			ul=ad(ad(ul*2)+1LL*f[i-1][j-1]*(j-1)%mod);
			f[i][j]=ad(ul+1LL*f[i-1][j]*(j+1)%mod);
		}
	}pr2(f[n][m]);
	return 0;
}