#include #include using namespace std; using mint = atcoder::modint998244353; using mint2 = atcoder::static_modint<1009>; int main(){ ios::sync_with_stdio(false); cin.tie(0); int m, n; cin >> m >> n; m++, n++; vector K(m), A(n); for(auto &&v : K) cin >> v; for(auto &&v : A) cin >> v; vector ans(1, 1), B(n); int prd = 1, idx = 0; auto safe = [&](vector &tmp){ for(auto &&v : tmp) v = v.val() % 1009; }; auto frobenius = [&](int ex){ vector tmp(1, 1); for(int i = 0; i < n; i++) B[i] = mint::raw(A[i]); while(ex){ if(ex & 1){ (tmp = convolution(tmp, B)).resize(n); safe(tmp); } if(ex >= 2){ (B = convolution(B, B)).resize(n); safe(B); } ex /= 2; } if(prd == 1009){ tmp[1] = tmp[1009]; tmp.resize(2); } return tmp; }; while(idx < m && prd < n){ (ans = convolution(ans, frobenius(K[idx++]))).resize(n); safe(ans); prd *= 1009; } mint2 coef = mint2::raw(A[0]).pow(accumulate(K.begin() + idx, K.end(), 0)); for(int i = 0; i < n; i++){ cout << (coef * ans[i].val()).val() << (i + 1 == n ? '\n' : ' '); } }