#include<bits/stdc++.h>
using namespace std;

#define int long long

int MOD;

vector<vector<int>> pro(vector<vector<int>>& a, vector<vector<int>>& b){
  vector<vector<int>> c(a.size(), vector<int>(b.size()));
  
  for(int i = 0; i < a.size(); i++){
    for(int j = 0; j < b[0].size(); j++){
      for(int k = 0; k < b.size(); k++){
        c[i][j] += a[i][k]*b[k][j];
        c[i][j] %= MOD;
      }
    }
  }

  return c;
}

vector<vector<int>> power(vector<vector<int>> a, int t){
  vector<vector<int>> res(a.size(), vector<int>(a.size()));
  
  for(int i = 0; i < a.size(); i++){
    res[i][i] = 1;
  }

  while(t){
    // cout<<t<<endl;
    if(t&1){
      res = pro(res, a);
    }
    a = pro(a,a);
    t >>= 1;
  }

  return res;
}

signed main(){
  
  while(true){
    int n, A, B, C, T;
    vector<vector<int>> mat, ans;

    cin>>n>>MOD>>A>>B>>C>>T;

    if(!n) break;

    ans.resize(n,vector<int>(1,0));
    mat.resize(n,vector<int>(n,0));
    
    for(int i = 0; i < n; i++){
      int S;
      
      cin>>S;
      
      ans[i][0] = S;
    }

    for(int i = 1; i < n-1; i++){
      mat[i][i-1] = A;
      mat[i][i] = B;
      mat[i][i+1] = C;
    }
    
    mat[0][0] = B;
    mat[0][1] = C;
    mat[n-1][n-2] = A;
    mat[n-1][n-1] = B;
    
    // cout<<"power "<<endl;
    
    mat = power(mat, T);
    
    //  cout<<"pro "<<endl;
    ans = pro(mat, ans);
    
    //cout<<"<> "<<endl;
    for(int i = 0; i < n; i++){
      if(i) cout<<" ";
      cout<<ans[i][0];
    }
    cout<<endl;
  }
  
  return 0;
}

