N, M = gets.split(" ").map{|s| s.to_i} a = gets.split(" ").map{|s| s.to_i} S = gets.strip.split("") lindex = 0 rindex = N-1 ln = rn = 1 S.each {|c| if c == "L" then ln += 1 if lindex == 0 and ln < N lindex -= 1 if lindex > 0 rindex -= 1 if rindex > 0 else rn += 1 if rindex == N-1 and rn < N rindex += 1 if rindex < N - 1 lindex += 1 if lindex < N - 1 end } ans = "" ans += "0 " * lindex if rindex == lindex then ans += a.sum.to_s elsif ln + rn == N then ans += a[0, ln].sum.to_s + " " + a[N-rn, rn].sum.to_s else ans += a[0, ln].sum.to_s + + " " + a[ln,N-ln-rn].map{|i| i.to_s}.join(" ") + " " + a[N-rn, rn].sum.to_s end ans += " 0" * (N-1-rindex) puts ans