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