#include <iostream>
#include <vector>
using namespace std;

long long int N, M;

typedef vector< vector<long long int> > matrix;

matrix mul(matrix a, matrix b)
{
	matrix res(N, vector<long long 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] += a[k][j] * b[i][k];
			}
			if(res[i][j] >= M)
				res[i][j] %= M;
		}
	}
	return res;
}

matrix pow(matrix m, int n)
{
	matrix res(N, vector<long long int>(N, 0));
	for (int i = 0; i < N; i++)
		res[i][i] = 1;
	int x = 1;
	while (x <= n) {
		if ((x & n) > 0) {
			res = mul(res, m);
		}
		m = mul(m, m);
		x <<= 1;
	}
	return res;
}

int main()
{
	long long int A, B, C, T;
	while (cin >> N >> M >> A >> B >> C >> T, N | M | A | B | C | T) {
		matrix bottom(N,vector<long long int>(N,0)),mat(N, vector<long long int>(N, 0)),res;
		for (int i = 0; i < N; i++) {
			if (i - 1 >= 0) {
				bottom[i][i - 1] = A;
			}
			bottom[i][i] = B;
			if (i + 1 < N) {
				bottom[i][i + 1] = C;
			}
		}
		for (int i = 0; i < N; i++) {
			cin >> mat[i][N - 1];
		}
		res = mul(mat, pow(bottom, T));
		for (int i = 0; i < N; i++) {
			cout << res[i][N - 1];
			if (i + 1 < N)
				cout << " ";
			else
				cout << endl;
		}
	}
	return 0;
}