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 x = a.shift a[0] += x a << 0 else x = a.pop a[-1] += x a.unshift(0) end } print a.map{|i| i.to_s}.join(" ")