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[0] = A[0]-1 dp[1] = 1 for i in range(1, n): temp = [0]*(n+1) for j in range(n+1): if j == 0: temp[j] = dp[j]*(A[i]-1) temp[j] %= mod else: temp[j] = dp[j-1]+dp[j]*(A[i]-1) temp[j] %= mod dp = temp for b in B: print(dp[b]%mod)