N, M = gets.split.map(&:to_i) A = gets.split.map(&:to_i) S = gets.chomp idx = 0 zure = 0 min_idx = Float::INFINITY max_idx = -Float::INFINITY S.each_char do |s| if s == 'L' idx -= 1 zure -= 1 else idx += 1 zure += 1 end zure = 0 if zure < 0 zure = N - 1 if N <= zure min_idx = idx if min_idx > idx max_idx = idx if max_idx < idx end min_idx.abs.times do if A.size >= 2 a1, a2 = A.shift(2) A.unshift(a1 + a2) end end max_idx.times do if A.size >= 2 a1, a2 = A.pop(2) A.push(a1 + a2) end end ans = Array.new(N, 0) A.each do |a| ans[zure] = a zure += 1 end puts ans.join(' ')