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