#include //#include //#include using namespace std; //using namespace boost::multiprecision; //using namespace atcoder; #define rep(i,n) for(int i=0;i<(n);++i) #define lep(i,n) for(long long i=0;i<(n);++i) #define all(x) (x).begin(),(x).end() #define rall(x) (x).begin(),(x).end() #define equals(a,b) (fabs((a)-(b)) using vc = vector; template using pp=pair; template using PQ = priority_queue,greater>; using vi=vc ; using vvi=vc; using vvvi=vc; using vl=vc; using vvl=vc; using vvvl=vc; using pi=pp; using pd=pp; using pl=pp; using pip=pp; using vpi=vc; using vvpi=vc; using vs=vc; using vss=vc; using vst=vc>; const int dx[4]={1,0,-1,0}; const int dy[4]={0,1,0,-1}; const int inf=1001001001; const ll infl=100100100100100100; const double eps=(1e-10); const ll mod=1000000007; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template void rprint(T &a) {printf("%.10f\n",a);} template void coutarray(vc& v) { rep(i, sz(v)) {cout << " "; cout << v[i];} cout << endl; } template void coutmatrix(vc>& v) { rep(i,sz(v)) { rep(j, sz(v[i])) {cout << " "; cout << v[i][j]; } cout << "\n";} }; struct mint{ ll x; mint(ll x=0) : x((x%mod+mod)%mod){ } mint operator -( )const{return mint(-x);} mint& operator +=(const mint &a) { if((x+=a.x)>=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){ return (*this)*=a.inv(); } mint operator+(const mint &a) const{return mint(*this)+=a;} mint operator-(const mint &a) const{return mint(*this)-=a;} mint operator*(const mint &a) const{return mint(*this)*=a;} mint operator/(const mint &a) const{return mint(*this)/=a;} mint pow(ll t)const{ if(!t)return 1; mint a=pow(t>>1); a*=a; if(t&1)a *= *this; return a; } mint inv() const{return pow(mod-2);} }; struct combination { vector fact, ifact; combination(int n):fact(n+1),ifact(n+1) { 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()(int n, int k) { if (k < 0 || n > prime_factorize(long long n) { vector > res; for (long long a = 2; a * a <= n; ++a) { if (n % a != 0) continue; long long ex = 0; while (n % a == 0) { ++ex; n /= a; } res.push_back({a, ex}); } if (n != 1) res.push_back({n, 1}); return res; } using vpl=vector; int main(){ int n,m; cin>>n>>m; mint now=0; combination com(200000); rep(i,m+1)now+=mint(i & 1 ? -1 : 1) * com(m, i) * mint(m-i).pow(n); cout<