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): NDP = [0] * (mex + 1) for j in range(mex+1): NDP[j] = (NDP[j] + ((M+1) - (mex-j)) * DP[j]) % MOD if mex != j: NDP[j+1] = (NDP[j+1] + (mex-j) * DP[j]) % MOD DP = NDP 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()