#include #include using namespace std; using namespace atcoder; using Mint = atcoder::modint998244353; int main() { int N, Q; scanf("%d%d",&N,&Q); deque> q; for (int i = 0; i < N; ++i) { long long a; scanf("%lld",&a); q.push_back(vector{a-1,1}); } while (q.size() > 1) { auto r = atcoder::convolution(q[0],q[1]); if (r.size() > N+1) r.resize(N+1); q.pop_front();q.pop_front(); q.push_back(r); } const auto &f = q.front(); for (int i = 0, b; i < Q; ++i) { scanf("%d", &b); printf("%u\n", f[b].val()); } }