#include #define int long long using namespace std; template inline bool chmax(T& a, T b){ if(a inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; } const int mod=1e9+7; const int sz=100005; int fact[sz],inv[sz],ifact[sz]; void make(){ fact[0]=fact[1]=inv[1]=ifact[0]=ifact[1]=1; for(int i=2;i=mod) a-=mod; } signed main() { int N,M; cin>>N>>M; make(); int ans=mod_pow(M,N); for(int i=1;i<=M;i++){ int tmp=comb(M,i)*mod_pow(M-i,N)%mod; if(i&1) add(ans,mod-tmp); else add(ans,tmp); } cout<