#include #include using namespace atcoder; using namespace std; #define all(a) a.begin(),a.end() #define rall(a) a.rbegin(),a.rend() #define fin(a) return pt(a) using ll=long long; using ld=long double; using pll=pair; templateusing ascending_priority_queue=std::priority_queue,greater>; templateusing descending_priority_queue=std::priority_queue; templatebool chmax(T&a,const T&b){if(abool chmin(T&a,const T&b){if(bT max(vector&vec,const T&id){T r=id;for(auto&v:vec)chmax(r,max(v,id));return r;} templateT min(vector&vec,const T&id){T r=id;for(auto&v:vec)chmin(r,min(v,id));return r;} templateT sum(vector&a){return accumulate(all(a),T(0));} templateT popcnt(T a){return __builtin_popcountll(a);} istream&operator>>(istream&is,modint1000000007&x){unsigned int t;is>>t;x=t;return is;} istream&operator>>(istream&is,modint998244353&x){unsigned int t;is>>t;x=t;return is;} istream&operator>>(istream&is,modint&x){unsigned int t;is>>t;x=t;return is;} ostream&operator<<(ostream&os,const modint1000000007&x){os<istream&operator>>(istream&is,pair&p){is>>p.first>>p.second;return is;} templateostream&operator<<(ostream&os,const pair&p){os<istream&operator>>(istream&is,vector&v){for(T&x:v)is>>x;return is;} templateostream&operator<<(ostream&os,const vector&v){for(int i=0;i<(int)v.size();i++){os<int pt_rest(){cout<<'\n';return 0;} templateint pt(){cout<<'\n';return 0;} templateint pt_rest(const T&first,const A&...rest){cout<<" "<int pt(const T&first,const A&...rest){cout<void resize(vector&vec,const H head){vec.resize(head);} templatevoid resize(vector&vec,const H&head,const T...tail){vec.resize(head);for(auto&v:vec)resize(v,tail...);} templatevoid fill(V&x,const T&val){x=val;} templatevoid fill(vector&vec,const T&val){for(auto&v:vec)fill(v,val);} templatevoid vin(istream&is,const int idx,vector&head){is>>head[idx];} templatevoid vin(istream&is,const int idx,vector&head,T&...tail){vin(is>>head[idx],idx,tail...);} templatevoid vin(istream&is,vector&head,T&...tail){for(int i=0;i<(int)head.size();i++)vin(is,i,head,tail...);} templatevoid vin(vector&head,T&...tail){vin(cin,head,tail...);} templatevoid sin(istream&is,H&head){is>>head;} templatevoid sin(istream&is,H&head,T&...tail){sin(is>>head,tail...);} templatevoid sin(H&head,T&...tail){sin(cin,head,tail...);} void divisor(ll n,map&div){for(ll i=1;i*i<=n;i++)if(n%i==0){div[i]++;div[n/i]++;}} void factrization(ll n,map&fact){for(ll i=2;i*i<=n;i++)while(n%i==0){fact[i]++;n/=i;}if(n>1)fact[n]++;} ll lsqrt(ll x){ll r=sqrt(x)-1;while((r+1)<=x/(r+1))r++;return r;}; ll inf=1LL<<60; ld pi=acos(-1); ld eps=1e-10; using v1=vector; using v2=vector; using v3=vector; using v4=vector; using mll=map; using S=ll; S op(S a,S b){return a+b;} S e(){return 0;} templatestruct Combination{ vectorfa,rfa,bs; vector>>mp; ll LIM=5000; Combination(ll n){ fa.resize(n+1); rfa.resize(n+1); fa[0]=rfa[0]=1; for(ll i=1;i<=n;i++)fa[i]=fa[i-1]*i; for(ll i=1;i<=n;i++)rfa[i]=rfa[i-1]/i; bs.resize(n+1); bs[0]=1; for(ll i=1;i<=n;i++)bs[i]=bs[i-1]+T(-1).pow(i&1)*rfa[i]; if(n<=LIM)mp.resize(n+1,vector>(n+1)); } T C(ll n,ll k){return n=0)return (mp[n][k]={true,p(n,k-1)+p(n-k,k)}).second; return (mp[n][k]={true,p(n,k-1)}).second; } }; int main(void){ cin.tie(nullptr); ios::sync_with_stdio(false); ll N,K;sin(N,K); using mint=modint998244353; Combinationcom(N); mint ans=0; for(ll i=1;i<=K;i++){ ans+=(K-i)*N*(mint(i).pow(N-1)-mint(i-1).pow(N-1))*i; ans+=(mint(i).pow(N)-mint(i-1).pow(N)-mint(i-1).pow(N-1)*N)*i; } pt(ans); }