def main(): MOD = 998244353 N, M = map(int, input().split()) invs = [0] + [pow(i, -1, MOD) for i in range(1, N+1)] f = [0] * (min(N, M+1) + 1) DP = [1] + [0] * min(N, M+1) C = 1 for iter in range(1, N+1): C = C * (N-iter+1) * invs[iter] % MOD mult = pow(M+1, N-iter, MOD) * C % MOD DP = [(i * DP[i] + (DP[i-1] if i != 0 else 0)) % MOD for i in range(len(DP))] f = [(f[i] + mult * DP[i]) % MOD for i in range(min(N, M+1)+1)] ans = 0 for mex in range(1, min(N, M+1)+1): mult = 1 for j in range(1, mex): mult = mult * j % MOD for i in range(mex, min(N, M+1)+1): mult = mult * i % MOD if i != mex: mult = mult * (M-i+1) * invs[i-mex] % MOD ans = (ans + mex * mult * f[i]) % MOD print(ans) if __name__ == '__main__': main()