#line 1 "main.cpp"
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, unsigned long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

#line 2 "/home/imperi/Documents/cp-library/lib/local/runtime_modint.cpp"

class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;
  static u64 Modulus;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  const u64 &value() const noexcept { return a; }
  bool operator==(const modint rhs) const noexcept {return a==rhs.a;}
  bool operator!=(const modint rhs) const noexcept {return !(*this==rhs);}
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};
#line 85 "main.cpp"

#line 2 "/home/imperi/Documents/cp-library/lib/math/DynamicMatrix.cpp"

#line 6 "/home/imperi/Documents/cp-library/lib/math/DynamicMatrix.cpp"

template <typename Field>
class DynamicMatrix{
  public:
  using value_t = Field;
  using size_t = std::size_t;

  private:
  size_t row, column;
  std::vector<std::vector<value_t>> a;

  public:
  explicit DynamicMatrix(size_t row_, size_t column_, value_t init_ = value_t())
      : row(row_), column(column_), a(row, std::vector<value_t>(column, init_)) {}

  constexpr value_t& operator()(size_t i, size_t j) { return a[i][j]; }
  constexpr bool operator==(const DynamicMatrix& rhs){
    if (row != rhs.row || column != rhs.column)return false;
    for (size_t i = 0; i < row; i++){
      for (size_t j = 0; j < column; j++){
        if (a[i][j] != rhs.a[i][j])return false;
      }
    }
    return true;
  }
  constexpr bool operator!=(const DynamicMatrix& rhs) { return !(*this == rhs); }

  constexpr DynamicMatrix operator+(const DynamicMatrix rhs){
    return DynamicMatrix(*this) += rhs;
  }
  constexpr DynamicMatrix operator-(const DynamicMatrix rhs){
    return DynamicMatrix(*this) -= rhs;
  }
  constexpr DynamicMatrix operator*(const DynamicMatrix rhs){
    return DynamicMatrix(*this) *= rhs;
  }

  constexpr DynamicMatrix& operator+=(const DynamicMatrix& rhs){
    assert(row == rhs.row && column == rhs.column);
    for (size_t i = 0; i < row; i++){
      for (size_t j = 0; j < column; j++){
        a[i][j] += rhs.a[i][j];
      }
    }
    return *this;
  }
  constexpr DynamicMatrix& operator-=(const DynamicMatrix& rhs){
    assert(row == rhs.row && column == rhs.column);
    for (size_t i = 0; i < row; i++){
      for (size_t j = 0; j < column; j++){
        a[i][j] -= rhs.a[i][j];
      }
    }
    return *this;
  }
  constexpr DynamicMatrix& operator*=(const DynamicMatrix& rhs){
    assert(column == rhs.row);
    std::vector<std::vector<value_t>> tmp(row, std::vector<value_t>(rhs.column, 0));
    for (size_t r = 0; r < row; r++){
      for (size_t c = 0; c < rhs.column; c++){
        for (size_t i = 0; i < column; i++){
          tmp[r][c] += a[r][i] * rhs.a[i][c];
        }
      }
    }
    column = rhs.column;
    a = std::move(tmp);
    return *this;
  }

  constexpr static DynamicMatrix id(size_t size){
    DynamicMatrix<Field> tmp(size, size);
    for (size_t i = 0; i < size; i++)tmp.a[i][i] = 1;
    return tmp;
  }
};
#line 87 "main.cpp"

std::uint_fast16_t modint::Modulus;

using mat=DynamicMatrix<modint>;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  ll n,a,b,c,t;

  while(std::cin>>n>>modint::Modulus>>a>>b>>c>>t,n){
    mat tmp(n,n);
    rep(i,0,n){
      if(i-1>=0)tmp(i,i-1)=a;
      tmp(i,i)=b;
      if(i+1<n)tmp(i,i+1)=c;
    }


    mat ret=mat::id(n);

    while(t>0){
      if(t&1)ret*=tmp;
      tmp*=tmp;
      t>>=1;
    }

    mat init(n,1);
    rep(i,0,n){
      ll e;
      std::cin>>e;
      init(i,0)=e;
    }

    ret*=init;

    rep(i,0,n)std::cout<<ret(i,0).value()<<(i!=n-1?" ":"");
    std::cout<<"\n";
  }

  return 0;
}



Measured memory_bytes: 3212