#include using ll=long long; constexpr int mod=998244353; constexpr int rev=748683265; ll my_pow(ll a,int b){ ll res=1; while(b){ if(b&1) res=res*a%mod; a=a*a%mod; b>>=1; } return res; } int main(){ int N,K; scanf("%d%d",&N,&K); printf("%d\n",(3*N+2*K+my_pow(N-2,K)*my_pow(N,mod-K)%mod)*rev%mod); }