MOD = 998244353 n, q = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) dp = [[0 for _ in range(n + 1)] for _ in range(n)] dp[0][0] = (a[0] - 1) % MOD dp[0][1] = 1 for i in range(1, n): dp[i][0] = (dp[i - 1][0] * (a[i] - 1)) % MOD for j in range(1, i + 2): dp[i][j] = (dp[i - 1][j] * (a[i] - 1) + dp[i - 1][j - 1]) % MOD for i in range(q): print(dp[-1][b[i]])