#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int mod = 1e9 + 7;
const int N = 5001;

int sum(int a, int b) {
	if ((a += b) >= mod) {
		a -= mod;
	}
	return a;
}

int n, m;
int dp[N][N];
int pw2[N];
int suf_dp[N][N + 1];

int main() {
	pw2[0] = 1;
	for (int i = 1; i < N; i++) {
		pw2[i] = sum(pw2[i - 1], pw2[i - 1]);
	}
	cin >> n >> m;
	dp[0][m] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = m; j >= 1; j--) {
			dp[i][j] = sum(1LL * (j + 1) * dp[i - 1][j] % mod, 1LL * j * suf_dp[i - 1][j + 1] % mod);
			suf_dp[i - 1][j] = sum(sum(suf_dp[i - 1][j + 1], suf_dp[i - 1][j + 1]), dp[i - 1][j]);
			/*for(int p = m; p >= j + 1; p--) {
				dp[i][j] = sum(dp[i][j], 1LL * dp[i - 1][p] * pw2[p - j - 1] % mod * j % mod);
			}*/
		}
	}
	int ans = 0;
	for (int rem = 1; rem <= m; rem++) {
		ans = sum(ans, dp[n][rem]);
	}
	cout << ans;
}
