#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int N=5005;
int n,m;
int Fac[N],Inv[N];
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
LL dp[N][N];
int main(){
	n=read(),m=read();
	Fac[0]=1;
	For(i,1,m)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[m]=Pow(Fac[m],mod-2);
	Fod(i,m,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	dp[0][1]=1;
	For(i,1,n){
		For(j,1,m){
			int v=dp[i-1][j];
			LL val=(LL)v*(j+1);
			dp[i][j]+=val;
			dp[i][j+1]-=val;
			dp[i][j+1]+=2LL*v*j;
		}
		For(j,1,m)
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
	}
	int ans=0;
	For(i,1,m)
		Add(ans,(LL)dp[n][i]*C(m-1,i-1)%mod);
	cout<<ans<<endl;
	return 0;
}