require 'matrix'

class SparseMatrix
	def initialize(m, n)
		@m, @n = m, n
		@rows = (1..m).map{ Hash.new(0) }
	end

	def [](i)
		@rows[i]
	end

	def rank
		save = Marshal.load(Marshal.dump(self))
		rank = 0
		j = 0
		(0..@m-1).each{|i|
			pivot_idx = nil
			j += 1 until j >= @n || pivot_idx = @rows.index{|row| row[j] && row[j] != 0}
			break if j >= @n
			rank += 1

			pivot_row = @rows.delete_at(pivot_idx)
			a = pivot_row[j]
			
			@rows.each{|row|
				b = row[j]
				if b && b != 0
					r = b / a
					pivot_row.each{|k, val|
						row[k] -= r * val
						row.delete(k) if row[k] == 0
					}
				end
			}

			j += 1
		}		
		@rows = save.rows
		rank
	end

	def map(&block)
		m = self.class.new(@m, @n)
		(0..@n-1).each{|i|
			@rows[i].each{|k, x|
				m[i][k] = block.call(x)
			}
		}
		m
	end

	def *(other)
		if other.kind_of?(Numeric)
			map{|x| x * other}
		elsif other.kind_of?(Vector)
			raise "hogehoge" if other.size != @n
			a = Array.new(@m, 0)
			(0..@m-1).each{|i|
				(0..@n-1).each{|j|
					 a[i] += @rows[i][j] * other[j]	
				}
			}
			Vector[*a]
		elsif other.kind_of?(SparseMatrix)
			prod = self.class.new(@m, @n)	
			(0..@m-1).each{|i|
				row = @rows[i]
				(0..other.n-1).each{|j|
					sum = 0
					@rows[i].each{|k, x|
						sum += x * other[k][j]	
					}
					prod[i][j] = sum if sum != 0
				}
			}
			prod
		else
			raise 'hoge'
		end

	end

	attr_reader :rows, :m, :n
end

def exp(n, k, mod = nil)
	x = 1	
	r = n
	while k > 0
		x = r * x if k & 1 == 1
		r *= r		
		if mod
			x %= mod
			r %= mod
		end
		k >>= 1
	end
	x
end

class SparseMatrix
	def %(mod)
		map{|x| x % mod}
	end
end

loop {
	n, m, a, b, c, t = gets.split.map &:to_i 
	break if n == 0
	states = Vector[*gets.split.map(&:to_i)]

	mat = SparseMatrix.new(n, n)
	(0..n-1).each{|i|
		(0..n-1).each{|j|
			if j == i-1
				mat[i][j] = a
			elsif j == i
				mat[i][j] = b
			elsif j == i+1
				mat[i][j] = c
			end
		}
	}

	puts (exp(mat, t, m) * states).to_a.map{|x| x % m}.join(" ")
}