#include using namespace std; #define int long long templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b struct Combination{ vector f, rf; Combination(int max_n): f(max_n+1), rf(max_n+1){ f[0] = 1; for(int i = 1;i <= max_n;i++) f[i] = f[i-1] * i % mod; int64_t a = f[max_n], inv = 1; for(int64_t b = mod-2;b > 0;b>>=1){ if(b & 1) inv = inv*a % mod; a = a * a % mod; } for(int i = max_n;i >= 0;i--) inv = (rf[i] = inv) * i % MOD; } int64_t operator()(int n, int r){ return (r < 0 || n < r) ? 0 : f[n] * rf[r] % mod * rf[n-r] % mod; } }; int pow_mod(int n, int m){ int ans = 1; while(m > 0){ if(m & 1) ans = (ans * n) % MOD; n = (n * n) % MOD; m >>= 1; } return ans; } signed main(){ int n, m; cin >> n >> m; Combination ncr(m); bool f = true; int ans = 0; for(int i = m;i >= 1;i--){ int tmp = pow_mod(i, n) * ncr(m, i); if(f){ ans = (ans + tmp) % MOD; }else{ ans = (MOD+ans-tmp) % MOD; } f = !f; } cout << ans << endl; return 0; }