import sys input = sys.stdin.readline N, Q = map(int, input().split()) a = list(map(int, input().split())) b = list(map(int, input().split())) mod = 998244353 dp = [0] * (N + 1) dp[1] = 1 dp[0] = a[0] - 1 #print(dp) for i in range(1, N): for j in range(N, -1, -1): if dp[j] == 0: continue dp[j + 1] += dp[j] dp[j + 1] %= mod dp[j] += dp[j] * (a[i] - 2) dp[j] %= mod for x in b: print(dp[x])