MOD = 998244353 half = pow(2, MOD - 2, MOD) N, M = map(int, input().split()) s = M * pow(M, N, MOD) % MOD for i in range(M): s -= pow(i, N, MOD) s %= MOD # print(s) answer = N * (M + 1) % MOD * s % MOD answer -= pow(M, N, MOD) * (M + 1) % MOD * N % MOD * (1 + M) % MOD * half % MOD print(answer)