#include <bits/stdc++.h>
using namespace std;
int N, M;
const signed long long mo = 1000000007;
signed long long dp[5050][5050];
signed long long p2[5050];
signed long long comb(signed long long N_, signed long long C_) {
  const int NUM_ = 400001;
  static signed long long fact[NUM_ + 1], factr[NUM_ + 1], inv[NUM_ + 1];
  if (fact[0] == 0) {
    inv[1] = fact[0] = factr[0] = 1;
    for (int i = 2; i <= NUM_; ++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
    for (int i = 1; i <= NUM_; ++i)
      fact[i] = fact[i - 1] * i % mo, factr[i] = factr[i - 1] * inv[i] % mo;
  }
  if (C_ < 0 || C_ > N_) return 0;
  return factr[C_] * fact[N_] % mo * factr[N_ - C_] % mo;
}
void solve() {
  int i, j, k, l, r, x, y;
  string s;
  cin >> N >> M;
  for (i = 0; i < (M + 1); i++) dp[0][i] = 1;
  p2[0] = 1;
  for (i = 0; i < (5010); i++) p2[i + 1] = p2[i] * 2 % mo;
  for (i = 1; i <= N; i++) {
    dp[i][0] = 1;
    for (x = 1; x <= M; x++) {
      (dp[i][x] += dp[i - 1][x] * (x + 1)) %= mo;
      for (int len = 2; len <= x; len++) {
        (dp[i][x] +=
         dp[i - 1][x - (len - 1)] * p2[len - 2] % mo * (x - len + 1)) %= mo;
      }
    }
  }
  cout << dp[N][M] << endl;
}
int main(int argc, char** argv) {
  string s;
  int i;
  if (argc == 1) ios::sync_with_stdio(false), cin.tie(0);
  for (i = 0; i < (argc - 1); i++) s += argv[i + 1], s += '\n';
  for (i = 0; i < (s.size()); i++) ungetc(s[s.size() - 1 - i], stdin);
  cout.tie(0);
  solve();
  return 0;
}
