#include #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") using namespace std; using ll=long long; const int mod=998244353; const int rev=(3ll*mod+1)/4; ll my_pow(ll a,ll 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); }