class Integer def mod_inverse(mod) self.pow(mod - 2, mod) end end N, K = gets.split.map(&:to_i) MOD = 998_244_353 all = K.pow(N, MOD) cnt = K * (K - 1) * N puts (cnt * all.mod_inverse(MOD)) % MOD