#include #include using namespace std; using mint = 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 mul = [&](const vector &lhs, const vector &rhs){ vector res(n); for(int i = 0; i < lhs.size(); i++){ for(int j = 0; i + j < n && j < rhs.size(); j++){ res[i + j] += lhs[i] * rhs[j]; } } return res; }; 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 = mul(tmp, B); ex /= 2; if(ex) B = mul(B, B); } if(prd == 1009){ vector res(1, tmp[0]); if(tmp.size() >= 2){ res.resize(1010); res[1009] = tmp[1]; } swap(res, tmp); } return tmp; }; while(idx < m && prd < n){ ans = mul(ans, frobenius(K[idx++])); prd *= 1009; } mint coef = mint::raw(A[0]).pow(accumulate(K.begin() + idx, K.end(), 0)); for(int i = 0; i < n; i++){ cout << (coef * ans[i]).val() << (i + 1 == n ? '\n' : ' '); } }