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