#include <bits/stdc++.h>

using namespace std;

long long MOD;

template <typename T>
struct ModInt {
  T x;
  ModInt() :x(0) {}
  ModInt(long long y) { x = y % MOD; if (x < 0) x += MOD; }

  ModInt& operator+=(const ModInt& a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator-=(const ModInt& a) {
    if ((x += MOD - a.x) >= MOD) x -= MOD;
    return *this;
  }
  ModInt& operator*=(const ModInt& a) {
    x = 1LL * x * a.x % MOD;
    return *this;
  }
  ModInt& operator/=(const ModInt& a) {
    *this *= a.inv();
    return *this;
  }

  ModInt operator+(const ModInt& a) const { return ModInt(x) += a; }
  ModInt operator-(const ModInt& a) const { return ModInt(x) -= a; }
  ModInt operator*(const ModInt& a) const { return ModInt(x) *= a; }
  ModInt operator/(const ModInt& a) const { return ModInt(x) /= a; }

  ModInt operator-() const { return ModInt(-x); }

  bool operator==(const ModInt a) const { return x == a.x; }
  bool operator!=(const ModInt a) const { return x != a.x; }
  bool operator<(const ModInt a) const { return x < a.x; }

  friend ostream& operator<<(ostream& os, const ModInt<T>& a) {
    return os << a.x;
  }
  friend istream& operator>>(istream& is, ModInt<T>& a) {
    T t; is >> t;
    a = ModInt(t);
    return is;
  }

  ModInt inv() const {
    T a = x, b = MOD, u = 1, v = 0;
    while (b > 0) {
      T t = a / b;
      swap((a -= t * b), b);
      swap((u -= t * v), v);
    }
    return ModInt(u);
  }

  ModInt pow(long long n) const {
    ModInt res(1), tmp(x);
    while (n > 0) {
      if (n & 1) res *= tmp;
      tmp *= tmp;
      n >>= 1;
    }
    return res;
  }

  static ModInt comb(long long n, long long k) {
    ModInt num(1), den(1);
    for (int i = 0; i < k; ++i) {
      num *= ModInt(n - i);
      den *= ModInt(i + 1);
    }
    return num / den;
  }
};

template <typename T>
class Matrix {
public:
  vector<vector<T> > A;

  Matrix() {}
  Matrix(size_t n) :A(n, vector<T>(n, 0)) {}
  Matrix(size_t n, size_t m) :A(n, vector<T>(m, 0)) {}
  Matrix(vector<vector<T> > A) :A(A) {}

  size_t height() const { return A.size(); }
  size_t width() const { return A[0].size(); }

  vector<T>& operator[](size_t k) { return A[k]; }
  const vector<T>& operator[](size_t k) const { return A[k]; }

  Matrix& operator+=(const Matrix& B) {
    size_t n = height(), m = width();
    assert(n == B.height() && m == B.width());
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < m; ++j)
        (*this)[i][j] += B[i][j];
    return *this;
  }
  Matrix& operator-=(const Matrix& B) {
    size_t n = height(), m = width();
    assert(n == B.height() && m == B.width());
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < m; ++j)
        (*this)[i][j] -= B[i][j];
    return *this;
  }
  Matrix& operator*=(const Matrix& B) {
    size_t n = height(), m = B.width(), p = width();
    assert(p == B.height());
    vector<vector<T> > C(n, vector<T>(m));
    for (size_t i = 0; i < n; ++i)
      for (size_t j = 0; j < m; ++j)
        for (size_t k = 0; k < p; ++k)
          C[i][j] += (*this)[i][k] * B[k][j];
    A.swap(C);
    return *this;
  }

  Matrix operator+(const Matrix& B) const { return Matrix(A) += B; }
  Matrix operator-(const Matrix& B) const { return Matrix(A) -= B; }
  Matrix operator*(const Matrix& B) const { return Matrix(A) *= B; }

  static Matrix Identity(size_t n) {
    Matrix I(n);
    for (size_t i = 0; i < n; ++i) I[i][i] = 1;
    return I;
  }

  Matrix pow(long long n) const {
    Matrix res = Matrix::Identity(height()), tmp(A);
    while (n > 0) {
      if (n & 1) res *= tmp;
      tmp *= tmp;
      n >>= 1;
    }
    return res;
  }
};

int main() {
  int N, M, A, B, C, T;
  while(cin >> N >> M >> A >> B >> C >> T, N) {
    MOD = M;
    Matrix<ModInt<long long> > S(N, 1), X(N);
    for (int i = 0; i < N; ++i) cin >> S[i][0];
    for (int i = 0; i < N; ++i)
      for (int j = 0; j < N; ++j)
        if (j == i - 1) X[i][j] = A;
        else if (j == i) X[i][j] = B;
        else if (j == i + 1) X[i][j] = C;
        else X[i][j] = 0;
    Matrix<ModInt<long long> > ans = X.pow(T);
    ans *= S;
    for(int i = 0; i < N; ++i) {
      if(i) cout << " ";
      cout << ans[i][0];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3200