#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<int> > mat_dot(vector<vector<int> > first, vector<vector<int> > second, int mod) {
	int n = first.size();
	vector<vector<int> > res(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < n; ++k) {
				res[i][j] += first[i][k] * second[k][j];
				res[i][j] %= mod;
			}
		}
	}
	return res;
}

vector<vector<int> > mat_pow(vector<vector<int> > mat, int exp, int mod) {
	int n = mat.size();
	vector<vector<int> > res(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) res[i][i] = 1;
	int cnt = 0;
	while ((1<<cnt) <= exp) {
		if ((exp>>cnt) & 1) res = mat_dot(res, mat, mod);
		mat = mat_dot(mat, mat, mod);
		cnt++;
	}
	return res;
}

int main() {
	while (1) {
		int n, m, a, b, c, t;
		cin >> n >> m >> a >> b >> c >> t;
		if (n == 0) break;
		vector<int> s(n);
		for (int i = 0; i < n; ++i) cin >> s[i];
		vector<vector<int> > mt(n, vector<int>(n));
		for (int i = 0; i < n; ++i) {
			if (i > 0) mt[i][i-1] = a;
			mt[i][i] = b;
			if (i < n-1) mt[i][i+1] = c;
		}
		mt = mat_pow(mt, t, m);
		vector<int> ans(n);
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				ans[i] += s[j] * mt[i][j];
				ans[i] %= m;
			}
			cout << (i ? " " : "") << ans[i];
		}
		cout << "\n";
	}
	return 0;
}
