#include <iostream>
using namespace std;
int main(void){
  for(;;){
    int N,M,A,B,C,T;
    cin >> N >> M >> A >> B >> C >> T;
    if(N == 0 && M == 0 && A == 0 && B == 0 && C == 0 && T == 0){ return 0; }
    int S[N+2];
    S[0] = 0; S[N+1] = 0;
    for(int i = 1 ; i <= N ; i++){cin >> S[i];}
    // matrix a
    int a[N+2][N+2];
    for(int i = 0 ; i <= N+1 ; i++){
      a[0][i] = 0; a[N+1][i] = 0;
    }
    for(int i = 1 ; i <= N ; i++){
      for(int j = 0 ; j <= N+1 ; j++){
	if(i == j+1)     {a[i][j] = A;}
	else if(i == j)  {a[i][j] = B;}
	else if(i == j-1){a[i][j] = C;}
	else             {a[i][j] = 0;}
      }
    }
    // culculate a^T mod M
    int  temp[N+2][N+2];
    int  ans [N+2][N+2];
    bool first = true;
    for(int i = 0 ; i <= N+1 ; i++){
      for(int j = 0 ; j <= N+1 ; j++){
	ans[i][j]=((i==j)?(1):(0));
      }
    }
    for(int p = 0 ; (1<<p) <= T ; p++){
      int tmp[N+2][N+2];
      if((T>>p) % 2 != 0){
	for(int i = 0 ; i <= N+1 ; i++){
	  for(int j = 0 ; j <= N+1 ; j++){
	    tmp[i][j] = 0;
	    for(int k = 0 ; k <= N+1 ; k++){
	      tmp[i][j] += ans[i][k] * a[k][j];
	    }
	  }
	}
	for(int i = 0 ; i <= N+1 ; i++){
	  for(int j = 0 ; j <= N+1 ; j++){
	    ans[i][j] = tmp[i][j] % M;
	  }
	}
      }
      for(int i = 0 ; i <= N+1 ; i++){
	for(int j = 0 ; j <= N+1 ; j++){
	  tmp[i][j] = 0;
	  for(int k = 0 ; k <= N+1 ; k++){
	    tmp[i][j] += a[i][k] * a[k][j];
	  }
	}
      }
      for(int i = 0 ; i <= N+1 ; i++){
	for(int j = 0 ; j <= N+1 ; j++){
	  a[i][j] = tmp[i][j] % M;
	}
      }
    }
    
    int ansv[N+2];
    for(int i = 0 ; i <= N+1 ; i++){
      ansv[i] = 0;
      for(int k = 0 ; k <= N+1 ; k++){
	ansv[i] += ans[i][k] * S[k];
      }
    }
    for(int i = 1 ; i <= N ; i++){
      cout << ansv[i] % M << ((i == N)?("\n"):(" "));
    }
  }
}

