#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
inline int sum(int a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
  return a;
}
inline void add(int &a, int b) {
  a += b;
  if (a >= MOD) {
    a -= MOD;
  }
}
inline int mult(int a, int b) { return (a * 1ll * b) % MOD; }
const int N = 5010;
int dp[N][N], pw[N];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  pw[0] = 1;
  for (int i = 1; i <= m; i++) {
    pw[i] = sum(pw[i - 1], pw[i - 1]);
  }
  for (int i = 0; i <= m; i++) {
    dp[i][0] = 1;
    for (int j = 1; j <= n; j++) {
      dp[i][j] = mult(dp[i][j - 1], i + 1);
      for (int len = 2; len <= i; len++) {
        add(dp[i][j],
            mult(pw[len - 2], mult(dp[i - len + 1][j - 1], i - len + 1)));
      }
    }
  }
  cout << dp[m][n] << '\n';
}
