N, Q = map(int, input().split()) P = 998244353 K = 96 A = [(int(a) - 1) % P for a in input().split()] m = int(("1" * 32 + "0" * 64) * 5010, 2) pa = (1 << 64) - ((1 << 64) % P) modP = lambda x: x - ((x & m) >> 64) * pa s = 1 for i, a in enumerate(A): s *= (1 << K) + a s = modP(s) t = bin(s)[2:] + "_" X = [int(t[-(i+1) * K - 1:-i * K - 1], 2) % P for i in range((len(t)+K-2) // K)] for a in [int(a) for a in input().split()]: print(X[a])