#include using namespace std; using ll=long long; ll pow_mod(ll a, ll n, ll mod){ if (n==0) return 1; else if (n&1) return (a*pow_mod(a,n-1,mod)%mod); else{ ll b=pow_mod(a,n/2,mod); return b*b%mod; } } int main(){ ll N, M; cin >> N >> M; ll Mod=998244353; ll X=pow_mod(M,N,Mod)*(M+1)%Mod; ll Y=0; for (int l=1; l<=M; l++) Y+=pow_mod(l,N,Mod); ll Z=(X-2*Y)%Mod; Z+=Mod; Z%=Mod; ll two_inv=pow_mod(2,Mod-2,Mod); N%=Mod; ll k=(N*two_inv)%Mod; k=(k*(M+1))%Mod; Z*=k; Z%=Mod; cout << Z << endl; }