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