### subroutines

def mulmod(n, m0, m1, mod)
  m = Array.new(n){Array.new(n)}
  for i in (0...n)
    for j in (0...n)
      mij = 0
      for k in (0...n)
        mij += m0[i][k] * m1[k][j]
      end
      m[i][j] = mij % mod
    end
  end
  m
end

def powmod(n, m0, t, mod)
  m = Array.new(n){Array.new(n){0}}
  (0...n).each{|i| m[i][i] = 1}

  while t > 0
    m = mulmod(n, m, m0, mod) if (t & 1) == 1
    m0 = mulmod(n, m0, m0, mod)
    t >>= 1
  end

  m
end

### main

loop do
  n, m, a, b, c, t = gets.split.map(&:to_i)
  break if (n | m | a | b | c | t) == 0

  v = gets.split.map(&:to_i)

  mat = Array.new(n){Array.new(n){0}}
  for i in (0...n)
    mat[i][i - 1] = a if i > 0
    mat[i][i] = b
    mat[i][i + 1] = c if i < n - 1
  end
  #p mat

  mat = powmod(n, mat, t, m)
  v0 = []

  for i in (0...n)
    vi = 0
    for j in (0...n)
      vi += mat[i][j] * v[j]
    end
    v0 << vi % m
  end

  puts v0.join(' ')
end