#include using namespace std; #define ll long long #define f(i,a,b) for(ll i=a;i=b;i--) #define rep(it,a) for(auto it: a) #define pb emplace_back #define mp make_pair #define vll vector #define pll pair #define MOD (1000LL*1000*1000+7) #define INF (MOD*MOD) #define F first #define S second #define all(a) a.begin(),a.end() #define tri pair #define vpll vector #define vvll vector #define LL(t) ll t;cin>>t #define VLL(v,n) vll v(n);f(i,0,n){cin>>v[i];} ll power(ll a, ll b, ll mod) { // return (a^b)%mod if(b==0) return 1; ll half=power(a,b / 2,mod); ll full=(half*half)%mod; return (b%2) ? (a*full)%mod : full; } ll divMod(ll a, ll b, ll mod){ // return (a/b) % mod , works iff a%b=0 return ((a%mod)*(power(b, MOD-2, MOD)))%mod; } bool comp(tri & a, tri &b){ if(a.first!=b.first) return a.first < b.first; else{ if(a.S.F!=b.S.F) return a.S.F < b.S.F; else return a.S.S < b.S.S; } } int main(){ ios_base::sync_with_stdio(false); cin.tie(nullptr); // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); LL(n);LL(m); vll fact(100001), factInv(100001); fact[0]=factInv[0]=1; f(i,1,100001){ fact[i]=(fact[i-1]*i)%MOD; factInv[i]=power(fact[i],MOD-2,MOD); } ll sum=0; f(i,0,m){ ll x=(((((fact[m]*power(m-i,n,MOD))%MOD)*factInv[i])%MOD)*factInv[m-i])%MOD; if(i%2){ sum-=x; } else sum+=x; sum%=MOD; } cout<