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

int N,M,A,B,C,T;
struct matrix{
    vector<vector<int>> m;
    matrix(int N){
        m = vector<vector<int>>(N,vector<int>(N,0));
    }
};

matrix mult(matrix& A,matrix& B){
    matrix C(N);
    for(int i=0;i<N;i++) for(int j=0;j<N;j++) for(int k=0;k<N;k++)
    (C.m[i][j] += A.m[i][k]*B.m[k][j])%=M;
    return C;
}

matrix pow(matrix& A,int n){
    if(n==1) return A;
    if(n&1){
        matrix P = pow(A,n-1);
        return mult(P,A);
    }else{
        matrix P = pow(A,n>>1);
        return mult(P,P);        
    }
}

void solve(vector<int>& S){
    if(T==0){
        for(int i=0;i<N;i++) cout << S[i] << (i!=N-1? " ":"\n");
        return ;
    }
    matrix X(N);
    for(int i=0;i<N;i++){
        if(i-1>=0) X.m[i][i-1] = A;
        X.m[i][i] = B;
        if(i+1<N) X.m[i][i+1] = C;
    }
    matrix res = pow(X,T);
    for(int i=0;i<N;i++){
        int ans = 0;
        for(int j=0;j<N;j++){
            (ans += res.m[i][j]*S[j])%=M;
        }
        cout << ans << (i!=N-1? " ":"\n");
    }
}

int main(){
    while(cin >> N >> M >> A >> B >> C >> T && N){
        vector<int> S(N);
        for(int i=0;i<N;i++) cin >> S[i];
        solve(S);
    }
}
