#include <bits/stdc++.h>
using namespace std;
template <typename ty1, typename ty2>
inline int add(ty1 x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  x += y;
  return x < 1000000007 ? x : x - 1000000007;
}
template <typename ty1, typename ty2>
inline void addto(ty1 &x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  x += y;
  if (x >= 1000000007) x -= 1000000007;
}
template <typename ty1, typename ty2>
inline int sub(ty1 x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  x -= y;
  return x < 0 ? x + 1000000007 : x;
}
template <typename ty1, typename ty2>
inline void subto(ty1 &x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  x -= y;
  if (x < 0) x += 1000000007;
}
template <typename ty1, typename ty2>
inline int mul(ty1 x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  return 1ll * x * y % 1000000007;
}
template <typename ty1, typename ty2>
void multo(ty1 &x, ty2 y) {
  if (y >= 1000000007) y %= 1000000007;
  if (x >= 1000000007) x %= 1000000007;
  x = 1ll * x * y % 1000000007;
}
long long int gcd(long long int a, long long int b) {
  if (a > b) {
    swap(a, b);
  }
  while (a) {
    swap(a, b);
    a %= b;
  }
  return b;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
long long int ppow(long long int i, long long int j) {
  long long int res = 1LL;
  while (j) {
    if ((j & 1LL)) {
      res *= i;
      if (res >= 1000000007) {
        res %= 1000000007;
      }
    }
    j >>= 1;
    i *= i;
    if (i >= 1000000007) {
      i %= 1000000007;
    }
  }
  return res;
}
class Combination {
 public:
  vector<long long int> k;
  vector<long long int> r;
  void resize(int N) {
    k.resize(N + 2);
    r.resize(N + 2);
    k[0] = 1;
    for (int i = 1; i < N + 2; i++) {
      k[i] = k[i - 1];
      k[i] *= i;
      if (k[i] >= 1000000007) k[i] %= 1000000007;
    }
    long long int al = k[k.size() - 1];
    long long int iv = ppow(k[k.size() - 1], 1000000007 - 2);
    r[k.size() - 1] = iv;
    for (int i = (int)(r.size()) - 2; i >= 0; i--) {
      r[i] = r[i + 1] * (i + 1);
      if (r[i] >= 1000000007) {
        r[i] %= 1000000007;
      }
    }
  }
  long long int C(int a, int b) {
    if (a < b) return 0;
    long long int up = k[a];
    long long int dw = r[b] * r[a - b];
    dw %= 1000000007;
    up *= dw;
    up %= 1000000007;
    return up;
  }
  long long int H(int a, int b) { return C(a + b - 1, b); }
  long long int catalan_number(int n) {
    return (C(2 * n, n) + 1000000007 - C(2 * n, n - 1)) % 1000000007;
  }
};
Combination C;
int n;
int m;
int dp[5002][5002];
bool use[5002][5002];
inline int dfs(int a, int b) {
  if (b == 0) return 0;
  if (a == n) return 1;
  if (use[a][b]) return dp[a][b];
  use[a][b] = true;
  addto(dp[a][b], mul(1 + b, dfs(a + 1, b)));
  for (int imi = 2; imi <= b; imi++) {
    addto(dp[a][b],
          mul(b - imi + 1, mul(ppow(2, imi - 2), dfs(a + 1, b - imi + 1))));
  }
  return dp[a][b];
}
int main() {
  cin >> n >> m;
  cout << dfs(0, m) << endl;
  return 0;
}
