#include using namespace std; //#define int long long #define all(v) (v).begin(), (v).end() #define rall(v) (v).rbegin(), (v).rend() #define rep(i,n) for(int i=0;i vi; typedef vector vc; typedef vector vb; typedef vector vd; typedef vector vs; typedef vector > vpii; typedef vector > vvi; typedef vector > vvc; typedef vector > vvb; typedef vector > vvd; typedef vector > vvs; typedef vector vl; typedef vector > vvl; typedef vector > > vvvl; ll MOD = 1000000007; const long long L_INF = 1LL << 60; const int INF = 2147483647; // 2^31-1 const double PI = acos(-1); //cout< inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;} template inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;} template void debug(T v){rep(i,v.size()) cout<= MOD) x -= MOD; return *this; } mint& operator-=(const mint a) { if ((x += MOD-a.x) >= MOD) x -= MOD; return *this; } mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this; } mint operator+(const mint a) const { mint res(*this); return res+=a; } mint operator-(const mint a) const { mint res(*this); return res-=a; } mint operator*(const mint a) const { mint res(*this); return res*=a; } mint pow(long long t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; } // for prime MOD mint inv() const { return pow(MOD-2); } mint& operator/=(const mint a) { return (*this) *= a.inv(); } mint operator/(const mint a) const { mint res(*this); return res/=a; } }; struct combination { vector fact, ifact; combination(long long n):fact(n+1),ifact(n+1) { assert(n < MOD); fact[0] = 1; for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i; ifact[n] = fact[n].inv(); for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i; } mint operator()(long long n, long long k) { if (k < 0 || k > n) return 0; return fact[n]*ifact[k]*ifact[n-k]; } }; //ホウジョ原理 signed main() { gearup; ll n,m; cin >> n >> m; combination C(m+10); mint res = 0; rep(i,m+1){ mint now = C(m,i) * mod_pow(m-i,n,MOD); if(i & 1)res-=now; else res+=now; } out(res.x); }