#include <iostream>
#include <vector>
#include <cassert>
using namespace std;


int M;

typedef vector<int> Vec;
typedef vector<Vec> Mat;
Mat operator*(const Mat& x, const Mat& y) {
    assert(x[0].size() == y.size());
    Mat r(x.size(), Vec(y[0].size()));
    for (size_t i = 0; i < r.size(); i++)
        for (size_t j = 0; j < r[0].size(); j++)
            for (size_t k = 0; k < y.size(); k++)
                r[i][j] = (r[i][j] + x[i][k] * y[k][j]) % M;
    return r;
}

vector<int> solve(int n, int a, int b, int c, int t, vector<int>& S) {
    // Make transition matrix
    Mat A(n, Vec(n));
    for (int i = 0; i < n; i++) {
        if (i - 1 >= 0) A[i][i-1] = a;
        A[i][i] = b;
        if (i + 1 < n) A[i][i+1] = c;
    }

    // Make initial state
    Mat x(n, Vec(1));
    for (int i = 0; i < n; i++) x[i][0] = S[i];

    // multiply t times
    while (t) {
        if (t & 1) x = A * x;
        A = A * A;
        t >>= 1;
    }
    
    // make answer
    vector<int> res(n);
    for (int i = 0; i < n; i++) res[i] = x[i][0];
    return res;
}

int main() {
    int N, A, B, C, T;
    while (true) {
        cin >> N >> M >> A >> B >> C >> T;
        if (N == 0 && M == 0 && A == 0 && B == 0 && C == 0 && T == 0)
            break;
        vector<int> S0(N);
        for (int i = 0; i < N; i++) cin >> S0[i];
        vector<int> res = solve(N, A, B, C, T, S0);
        for (size_t i = 0; i < res.size(); i++) {
            cout << res[i];
            cout << (i != res.size() - 1 ? " " : "\n");
        }
    }
}