#include using namespace std; const long m = 1000000007; const long p = 500000006; int a, b; long dp[5001][5001]; long mpow(long b, long e) { if (e == 0) return 1; if (e % 2 == 1) return b * mpow(b, e - 1) % m; long t = mpow(b, e / 2); return t * t % m; } int main() { cin >> a >> b; dp[0][0] = 1; for (int i = 0; i < a; ++i) { for (int j = 0; j <= i; ++j) { (dp[i + 1][j + 1] += dp[i][j]) %= m; (dp[i + 1][j] += j * dp[i][j]) %= m; } } long f = 1; long sum = 0; for (int j = 0; j <= a; ++j) { long l = dp[a][j] * f % m; long r = mpow(p - j, b); (sum += l * r) %= m; f = f * (p - j) % m; } cout << sum << endl; }