#include <iostream>
#include <algorithm>
#include <vector>
#include <string>


class ModInt {
    using lint = long long;

public:
    static int MOD;
    int val;

    // constructor
    ModInt(lint v = 0) : val(v % MOD) {
        if (val < 0) val += MOD;
    };

    // assignment
    ModInt& operator=(const ModInt& x) {
        if (this != &x) { this->val = x.val; }
        return *this;
    }

    // unary operator
    ModInt operator+() const { return ModInt(val); }
    ModInt operator-() const { return ModInt(MOD - val); }
    ModInt operator~() const { return *this ^ (MOD - 2); }

    // increment / decrement
    ModInt& operator++() { return *this += 1; }
    ModInt& operator--() { return *this -= 1; }
    ModInt operator++(int) {
        ModInt before = *this;
        ++(*this);
        return before;
    }
    ModInt operator--(int) {
        ModInt before = *this;
        --(*this);
        return before;
    }

    // arithmetic
    ModInt operator+(const ModInt& x) const { return ModInt(*this) += x; }
    ModInt operator-(const ModInt& x) const { return ModInt(*this) -= x; }
    ModInt operator*(const ModInt& x) const { return ModInt(*this) *= x; }
    ModInt operator%(const ModInt& x) const { return ModInt(*this) %= x; }
    ModInt operator/(const ModInt& x) const { return ModInt(*this) /= x; }
    ModInt operator^(const ModInt& x) const { return ModInt(*this) ^= x; }

    // compound assignment
    ModInt& operator+=(const ModInt& x) {
        if ((val += x.val) >= MOD) val -= MOD;
        return *this;
    }
    ModInt& operator-=(const ModInt& x) {
        if ((val -= x.val) < 0) val += MOD;
        return *this;
    }
    ModInt& operator*=(const ModInt& x) {
        val = lint(val) * x.val % MOD;
        return *this;
    }
    ModInt& operator%=(const ModInt& x) {
        val %= x.val;
        return *this;
    }
    ModInt& operator/=(const ModInt& x) { return *this *= ~x; }
    ModInt& operator^=(const ModInt& x) {
        int n = x.val;
        ModInt b = *this;
        if (n < 0) n = -n, b = ~b;

        *this = 1;
        while (n > 0) {
            if (n & 1) *this *= b;
            n >>= 1;
            b *= b;
        }
        return *this;
    }

    // compare
    bool operator==(const ModInt& b) const { return val == b.val; }
    bool operator!=(const ModInt& b) const { return val != b.val; }
    bool operator<(const ModInt& b) const { return val < b.val; }
    bool operator<=(const ModInt& b) const { return val <= b.val; }
    bool operator>(const ModInt& b) const { return val > b.val; }
    bool operator>=(const ModInt& b) const { return val >= b.val; }

    // I/O
    friend std::ostream& operator<<(std::ostream& os, const ModInt& x) noexcept { return os << x.val; }
    friend std::istream& operator>>(std::istream& is, ModInt& x) noexcept { return is >> x.val; }
};

int ModInt::MOD = 0;


template <class T>
using Matrix = std::vector<std::vector<T>>;

template <class T>
Matrix<T> operator*(const Matrix<T>& a, const Matrix<T>& b) {
    int n = a.size(), m = b.size(), l = b.front().size();
    Matrix<T> ret(n, std::vector<T>(l, 0));

    for (int i = 0; i < n; ++i) {
        for (int k = 0; k < l; ++k) {
            for (int j = 0; j < m; ++j) {
                ret[i][k] += a[i][j] * b[j][k];
            }
        }
    }
    return ret;
}

template <class T>
std::vector<T> operator*(const Matrix<T>& a, const std::vector<T>& v) {
    int n = a.size(), m = v.size();
    std::vector<T> ret(n, 0);

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            ret[i] += a[i][j] * v[j];
        }
    }
    return ret;
}

using namespace std;

using lint = long long;
using ldouble = long double;

template <class T>
Matrix<T> mpow(Matrix<T> b, lint n) {
    Matrix<T> ret(b.size(), vector<T>(b.size(), 0));
    for (int i = 0; i < b.size(); ++i) ret[i][i] = 1;

    while (n > 0) {
        if (n & 1) ret = ret * b;
        n >>= 1;
        b = b * b;
    }
    return ret;
}

bool solve() {
    int n, m, a, b, c, t;
    cin >> n >> m >> a >> b >> c >> t;
    if (n == 0) return false;

    ModInt::MOD = m;
    vector<ModInt> v(n);
    for (auto& e : v) cin >> e;

    Matrix<ModInt> mat(n, vector<ModInt>(n, 0));
    for (int i = 0; i < n; ++i) {
        if (i - 1 >= 0) mat[i][i - 1] = a;
        mat[i][i] = b;
        if (i + 1 < n) mat[i][i + 1] = c;
    }

    v = mpow(mat, t) * v;
    for (int i = 0; i < n; ++i) {
        cout << v[i] << " \n"[i == n - 1];
    }
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



Measured memory_bytes: 3116