N,K=map(int,input().split()) M=998244353 print((3*N+2*K+pow(N-2,K,M)*pow(N,M-K,M))*748683265%M)