#include <bits/stdc++.h>

using namespace std;

typedef long long Int;
typedef vector<Int> vec;
typedef vector<vec> mat;

int mod;

mat mul(mat &A, mat &B)
{
    mat C(A.size(), vec(B[0].size()));
    
    for (int i = 0; i < A.size(); i++){
        for (int j = 0; j < B[0].size(); j++){
            for (int k = 0; k < A[0].size(); k++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    
    return (C);
}

mat pow(mat &A, Int n)
{
    mat B(A.size(), vec(A.size()));
    
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    
    while (n > 0){
        if (n & 1){
            B = mul(B, A);
        }
        A = mul(A, A);
        n >>= 1;
    }
    
    return (B);
}

int main()
{
	int n, m, a, b, c, t;
	int S[64];

	while (scanf("%d %d %d %d %d %d", &n, &m, &a, &b, &c, &t) && n){
		for (int i = 0; i < n; i++) scanf("%d", S + i);
		mat X(n, vec(n));
		for (int i = 0; i < n; i++){
			if (i) X[i][i - 1] = a;
			X[i][i] = b;
			if (i < n - 1) X[i][i + 1] = c;
		}
		mod = m;
		X = pow(X, t);
		for (int i = 0; i < n; i++){
			Int ans = 0;
			for (int j = 0; j < n; j++) ans = (ans + X[i][j] * S[j]) % m;
			printf("%lld%c", ans, " \n"[i + 1 == n]);
		}
	}

	return (0);
}