MOD = 998244353 max_n = 2000 # Precompute combinations C(n, m) modulo MOD C = [[0] * (max_n + 1) for _ in range(max_n + 1)] C[0][0] = 1 for n in range(1, max_n + 1): C[n][0] = 1 for m in range(1, n + 1): C[n][m] = (C[n-1][m-1] + C[n-1][m]) % MOD # Read input N, M = map(int, input().split()) total = 0 K = min(M, N) # Handle k from 1 to K for k in range(1, K + 1): current_sum = 0 for s in range(0, k + 1): term = (2 * M - s + 1) % MOD term_pow = pow(term, N, MOD) sign = (-1) ** s comb = C[k][s] if sign < 0: comb = (-comb) % MOD current_sum = (current_sum + comb * term_pow) % MOD contribution = k * current_sum % MOD total = (total + contribution) % MOD # Handle k = M+1 if applicable if M + 1 <= N: k = M + 1 current_sum = 0 for s in range(0, k + 1): term = (2 * (M + 1) - s) % MOD term_pow = pow(term, N, MOD) sign = (-1) ** s comb = C[k][s] if sign < 0: comb = (-comb) % MOD current_sum = (current_sum + comb * term_pow) % MOD contribution = (M + 1) * current_sum % MOD total = (total + contribution) % MOD print(total % MOD)