#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //eolibraries #define lnf 3999999999999999999 #define inf 999999999 #define fi first #define se second #define pb push_back #define ll long long #define ld long double #define all(c) (c).begin(),(c).end() #define sz(c) (int)(c).size() #define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()) #define pii pair #define rep(i,n) for(int i = 0 ; i < n ; i++) #define drep(i,n) for(int i = n-1 ; i >= 0 ; i--) #define crep(i,x,n) for(int i = x ; i < n ; i++) #define vi vector #define vec(...) vector<__VA_ARGS__> #define fcin ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); //eodefine using namespace std; const int max_n = 103002; const ll mod = 998244353; ll n,m; ll binpow(ll a, ll b) { a %= mod; ll res = 1; while (b) { if (b%2) res = res * a % mod; a = a * a % mod; b /= 2; } return res % mod; } ll fact[max_n],invfact[max_n]; void prefact() { fact[0]=fact[1]=1; invfact[1]=1; rep(i,max_n-3){ if(i>1)fact[i] = fact[i-1]*i; fact[i] %= mod; if(i>1)invfact[i]=mod-invfact[mod%i]*(mod/i)%mod; } } ll sub(ll a , ll b){ a%=mod; b%=mod; return (((a-b)%mod)+mod)%mod; } ll prod(ll a , ll b){ a%=mod; b%=mod; return ((a*b)%mod); } ll add(ll a , ll b){ a%=mod; b%=mod; return (a+b)%mod; } ll f(ll i){ return (i*(i+1))/2; } int main(){ fcin; prefact(); cin>>n>>m; ll ans=0,g=0; drep(i,m+1){ if(i==0)break; // ll k=() ll x=binpow((m-i+1),n-1); ll sum=f(m)-f(i-1); ll d = prod(x,prod(sum,n)); d = sub(d,g); ans = sub(ans,prod(i,d)); // cout<