N, M = gets.split(" ").map{|s| s.to_i} a = gets.split(" ").map{|s| s.to_i} S = gets.strip.split("") S.each {|c| if c == "L" then a[1] += a[0] a.shift a << 0 else a[-2] += a[-1] a.pop a.unshift(0) end } print a.map{|i| i.to_s}.join(" ")