#include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; #include using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; template class NTT { void bit_reverse(vector& a){ int N = a.size(); int i = 0; for(int j=1; j>1; k>(i^=k); k>>=1); if(j < i) swap(a[i], a[j]); } } ll extgcd(ll a, ll b, ll &x, ll &y){ ll d = a; if(b!=0){ d = extgcd(b,a%b,y,x); y -= (a/b)*x; }else{ x = 1; y = 0; } return d; } ll mod_inv(ll a){ ll x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; } ll mod_pow(ll x, ll n){ if(n==0) return 1; ll res = mod_pow(x * x % mod, n / 2); if(n & 1) res = res * x % mod; return res; } void _calc(vector& a, int sign){ int N = a.size(); ll g = primitive_root; ll tmp = (mod - 1) * mod_inv(N) % mod; ll h = mod_pow(g, tmp); if(sign == -1) h = mod_inv(h); bit_reverse(a); for(int m=1; m& in){ _calc(in, 1); } void intt(vector& in){ _calc(in, -1); ll n_inv = mod_inv(in.size()); for(int i=0; i conv(const vector& a, const vector& b){ vector _a = a, _b = b; int m = a.size() + b.size() - 1; int n = 1; while(n < m) n <<= 1; _a.resize(n, 0); _b.resize(n, 0); ntt(_a); ntt(_b); for(int i=0; i& xs, vector& mods){ int M = xs.size(); vector coefs(M, 1), con(M, 0); for(int i=0; i conv(vector& a, vector& b, ll mod){ for(int i=0; i ntt1; NTT<469762049LL, 3> ntt2; NTT<1224736769LL, 3> ntt3; vector x1 = ntt1.conv(a, b); vector x2 = ntt2.conv(a, b); vector x3 = ntt3.conv(a, b); vector ret(x1.size()); vector mods{167772161LL, 469762049LL, 1224736769L, mod}; for(int i=0; i xs{x1[i], x2[i], x3[i], 0}; ret[i] = garner(xs, mods); } return ret; } }; Garner garner; vector solve(const vector& v, int l, int m, int r){ if(l == m) return vector{1, v[l]-1}; vector lhs = solve(v, l, (l+m)/2, m); vector rhs = solve(v, m, (m+r)/2, r); return garner.conv(lhs, rhs, 998244353); } int main(){ int N, Q; cin >> N >> Q; vector v; rep(i,N){ ll a; cin >> a; v.push_back(a); } vector ret = solve(v, 0, v.size()/2, v.size()); reverse(ALLOF(ret)); rep(i,Q){ int b; cin >> b; cout << ret[b] << endl; } return 0; }