#include <cstdio>
#include <vector>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 5005;

int N, M, f[MN][MN];

int main() {
	scanf("%d%d", &N, &M);
	for (int j = 1; j <= M; ++j) f[0][j] = 1;
	for (int i = 1; i <= N; ++i) {
		for (int j = 2; j <= M; ++j)
			f[i][j] = (2 * f[i][j - 1] + (LL)f[i - 1][j - 1] * (j - 1)) % Mod;
		for (int j = 1; j <= M; ++j)
			f[i][j] = (f[i][j] + (LL)f[i - 1][j] * (j + 1)) % Mod;
	}
	printf("%d\n", f[N][M]);
	return 0;
}