MOD = 998244353 N, Q = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) dp = [0] * (N + 2) dp[0] = 1 for i in range(N): for j in reversed(range(N + 1)): dp[j] += dp[j - 1] * (A[i] - 1) dp[j] %= MOD dp = dp[::-1][1:] for b in B: print(dp[b])