## https://yukicoder.me/problems/no/1552 MOD = 998244353 def my_pow(a, x): if a == 0: return 0 else: return pow(a, x, MOD) def linear_sum(N): ans = (N * (N + 1)) % MOD ans *= pow(2, MOD - 2, MOD) ans %= MOD return ans def main(): N, M = map(int, input().split()) # 最小値から考える answer_min = 0 max_linear_sum = linear_sum(M) for m in range(1, M + 1): min_linear_sum = linear_sum(m - 1) diff_linear_sum = (max_linear_sum - min_linear_sum) % MOD m0 = M - m + 1 m0 = my_pow(m0, N - 1) m0 *= N m0 %= MOD a = (diff_linear_sum * m0) % MOD min_linear_sum2 = linear_sum(m) diff_linear_sum2 = (max_linear_sum - min_linear_sum2) % MOD b = my_pow(diff_linear_sum2, N) m0 = M - m m0 = my_pow(m0, N - 1) m0 *= N m0 %= MOD b = (diff_linear_sum2 * m0) % MOD c = (a - b) % MOD ans = (c * m) % MOD answer_min += ans answer_min %= MOD # 最大値 answer_max = 0 for m in range(1, M + 1): max_linear_sum = linear_sum(m) m0 = m m0 = my_pow(m0, N - 1) m0 *= N m0 %= MOD a = (max_linear_sum * m0) % MOD max_linear_sum2 = linear_sum(m - 1) m0 = m - 1 m0 = my_pow(m0, N - 1) m0 *= N m0 %= MOD b = (max_linear_sum2 * m0) % MOD c = (a - b) % MOD ans = (c * m) % MOD answer_max += ans answer_max %= MOD answer = (answer_max - answer_min) % MOD print(answer) if __name__ == "__main__": main()