#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef vector<int>vec;
typedef vector<vec>mat;

int n, m, a, b, c, t;
mat mul(mat&a, mat&b) {
	mat c(a.size(), vec(b[0].size()));
	rep(i, a.size())rep(j, b[0].size())rep(k, b.size())
		(c[i][j] += a[i][k] * b[k][j]) %= m;
	return c;
}
mat ppow(mat&a, int b) {
	mat res(a.size(), vec(a.size()));
	rep(i, a.size())res[i][i] = 1;
	while (b) {
		if (b & 1)res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}
int main() {
	while (scanf("%d%d%d%d%d%d", &n, &m, &a, &b, &c, &t), n) {
		mat A(n, vec(n)), B(n, vec(1));
		rep(i, n)scanf("%d", &B[i][0]);
		rep(i, n)rep(j, n) {
			if (j == i - 1)A[i][j] = a;
			if (j == i)A[i][j] = b;
			if (j == i + 1)A[i][j] = c;
		}
		A = ppow(A, t);
		A = mul(A, B);
		rep(i, n) {
			if (i)printf(" ");
			printf("%d", A[i][0]);
		}
		puts("");
	}
}