def r():return input().split() N,_=map(int,r()) t=[0]*(N+2) t[0]=1 for a in map(int,r()): for i in range(N,-1,-1): t[i]=(t[i]*(a-1)+t[i-1])%998244353 for b in map(int,r()): print(t[b])