#include #include using namespace std; using ll = long long; using mint = atcoder::modint; int main(){ ios::sync_with_stdio(false); cin.tie(0); ll n, m, p, v; cin >> n >> m >> p; mint::set_mod(p); vector a(n + 1), ans(n + 1); for(int i = 1; i <= n; i++){ cin >> v; a[i] = v; } auto mul = [&](vector &lhs, vector &rhs){ vector res(n + 1), c(n + 1); for(int i = 1; i <= n; i++){ for(int j = 1; i + j <= n; j++){ c[i + j] += lhs[i] * rhs[j]; } } for(int i = 1; i <= n; i++){ for(int j = 1; j < i; j++){ res[i] += res[j] * c[i - j]; } res[i] += lhs[i] + rhs[i]; } return res; }; while(m){ if(m & 1) ans = mul(ans, a); a = mul(a, a); m /= 2; } for(int i = 1; i <= n; i++) cout << ans[i].val() << (i == n ? '\n' : ' '); }