#include <cstdio>
#include <utility>
#include <algorithm>
#include <vector>
#include <cstdint>

using Matrix=std::vector<std::vector<intmax_t>>;

Matrix matpow(Matrix &Q, intmax_t T, intmax_t M) {
  Matrix zero=Matrix(Q.size());
  for (size_t i=0; i<zero.size(); ++i)
    zero[i].resize(Q.size());

  Matrix eye=zero;
  for (size_t i=0; i<eye.size(); ++i)
    eye[i][i] = 1;

  Matrix res=eye;
  Matrix pow=Q;

  while (T) {
    if (T & 1) {
      // res *= pow;
      Matrix tmp=zero;
      for (size_t i=0; i<Q.size(); ++i)
	for (size_t j=0; j<Q.size(); ++j)
	  for (size_t k=0; k<Q.size(); ++k) {
	    tmp[i][j] += res[i][k] * pow[k][j];
	    tmp[i][j] %= M;
	  }

      res = std::move(tmp);
    }

    {
      // pow *= pow;
      Matrix tmp=zero;
      for (size_t i=0; i<Q.size(); ++i)
	for (size_t j=0; j<Q.size(); ++j)
	  for (size_t k=0; k<Q.size(); ++k) {
	    tmp[i][j] += pow[i][k] * pow[k][j];
	    tmp[i][j] %= M;
	  }
    
      pow = std::move(tmp);
    }

    T >>= 1;
  }

  return res;
}

int testcase_ends() {
  intmax_t N, M, A, B, C, T;
  scanf("%jd %jd %jd %jd %jd %jd", &N, &M, &A, &B, &C, &T);

  if (N == 0)
    return 1;

  std::vector<intmax_t> S(N+2);
  for (int i=1; i<=N; ++i)
    scanf("%jd", &S[i]);

  std::vector<std::vector<intmax_t>> Q(N+2, std::vector<intmax_t>(N+2));
  for (int i=1; i<N+1; ++i) Q[i][i] = B;
  for (int i=1; i<N+1; ++i) {
    Q[i][i-1] = A;
    Q[i][i+1] = C;
  }

  Matrix R=matpow(Q, T, M);

  std::vector<intmax_t> res(N+2);
  for (int i=0; i<=N+1; ++i)
    for (int j=0; j<=N+1; ++j) {
      res[i] += R[i][j] * S[j];
      res[i] %= M;
    }

  for (int i=1; i<=N; ++i)
    printf("%jd%c", res[i], i<N? ' ':'\n');

  return 0;
}

int main() {
  while (!testcase_ends()) {}

  return 0;
}