n,q=map(int,input().split()) M=998244353 a=list(map(int,input().split())) q=[0]*(n+1) q[0]=1 for v in a: nq=[0]*(n+1) for i in range(n+1): nq[i]+=q[i]*(v-1) nq[i]%=M if i+1<=n: nq[i+1]+=q[i]*1 nq[i+1]%=M q=nq b=list(map(int,input().split())) for v in b: print(q[v])