#include #include using namespace std; using ll = long long; #define rep(i, s, t) for (ll i = s; i < (ll)(t); i++) #define all(x) begin(x), end(x) template bool chmin(T& x, T y) { return x > y ? (x = y, true) : false; } template bool chmax(T& x, T y) { return x < y ? (x = y, true) : false; } struct io_setup { io_setup() { ios::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(15); } } io_setup; using mint = atcoder::modint; vector comp(vector a, vector b, int mx) { vector v(mx, 0); rep(i, 0, mx) rep(j, 0, mx - i) { v[i + j] = a[i] * b[j]; } vector res(mx, 0); rep(i, 0, mx) { res[i] = a[i] + b[i]; rep(j, 0, i - 1) { res[i] += res[j] * v[i - 2 - j]; } } return res; } void solve() { ll n, m, p; cin >> n >> m >> p; mint::set_mod(p); vector a(n); rep(i, 0, n) { ll x; cin >> x; a[i] = x; } vector> pw(60); pw[0] = a; rep(i, 1, 60) pw[i] = comp(pw[i - 1], pw[i - 1], n); vector ans(n, 0); rep(i, 0, 60) { if ((m >> i) & 1) ans = comp(ans, pw[i], n); } rep(i, 0, n) cout << ans[i].val() << ' '; cout << '\n'; } int main() { int t = 1; // cin >> t; while (t--) solve(); }