N, Q = map(int, input().split()) P = 998244353 K = 192 KK = 1 << K A = [1] * 8192 + [KK + (int(a) - 1) % P for a in input().split()] + [1] * (8192 - N) m = int(("1" * 64 + "0" * 128) * 5010, 2) pa = (1 << 128) - ((1 << 128) % P) modP = lambda x: x - ((x & m) >> 128) * pa for i in range(8191, 0, -1): A[i] = modP(A[2*i] * A[2*i+1]) t = bin(A[1])[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])