#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef lli elm;
typedef vector<elm> vec;
typedef vector<vec> mat;

lli N, M, A, B, C, T;

mat getE(int n) {
  mat e(n, vec(n, 0));
  for(int i = 0; i < n; ++i) {
    e[i][i] = 1;
  }
  return e;
}

mat multiply(const mat &a, const mat &b) {
  if(a.size() == 0 || b.size() == 0 ||
     a[0].size() != b.size()) return mat();
  int s = a.size();
  int t = b.size();
  int u = b[0].size();
  mat c(s, vec(u, 0));
  for(int i = 0; i < s; ++i) {
    for(int j = 0; j < u; ++j) {
      for(int k = 0; k < t; ++k) {
        ( c[i][j] += a[i][k] * b[k][j] % M ) %= M;
      }
    }
  }
  return c;
}

mat pow(const mat &a, const lli &n) {
  if(n == 0) return getE(a.size());
  mat b = pow(multiply(a, a), n/2);
  if(n & 1) return multiply(b, a);
  else return b;
}

int main() {
  while(cin >> N >> M >> A >> B >> C >> T &&
        (N|M|A|B|C|T)) {
    mat S(N, vec(1));
    for(int i = 0; i < N; ++i) cin >> S[i][0];

    mat D(N, vec(N));
    for(int i = 0; i < N; ++i) {
      if(i-1 >= 0) D[i][i-1] = A;
      D[i][i] = B;
      if(i+1 < N) D[i][i+1] = C;
    }
    D = pow(D, T);
    S = multiply(D, S);
    for(int i = 0; i < N; ++i) {
      if(i) cout << " ";
      cout << S[i][0];
    }
    cout << endl;
  }
  return 0;
}