MOD = 998244353 n, q = map(int, input().split()) A = list(map(int, input().split())) s = [a - 1 for a in A] queries = list(map(int, input().split())) dp = [0] * (n + 1) dp[0] = 1 for i in range(n): a = s[i] for j in range(i + 1, 0, -1): dp[j] = (dp[j] * a + dp[j - 1]) % MOD dp[0] = (dp[0] * a) % MOD result = [str(dp[b]) if b <= n else '0' for b in queries] print(' '.join(result))