#pragma GCC target("avx2") #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include #include #include #include using namespace std; using Mint = atcoder::modint998244353; vector q[20000]; int main() { int N, Q; scanf("%d%d", &N, &Q); int li = 0, ri = 0; for (int i = 0; i < N; ++i) { int a; scanf("%d", &a); q[ri++] = vector{Mint(a - 1), Mint(1)}; } const int z = N + 1; while (ri - li > 1) { auto r = atcoder::convolution(move(q[li]), move(q[li + 1])); if (int(r.size()) > z) r.resize(z); while (r.back() == 0) r.pop_back(); li += 2; q[ri++] = move(r); } const auto &f = q[li]; for (int i = 0; i < Q; ++i) { int b; scanf("%d", &b); printf("%u\n", f[b].val()); } }