#include using namespace std; #define ll long long #define rep(i, n) for (int i = 0; i < (n); i++) #define P pair int main() { int n, m; cin >> n >> m; deque deq; rep(i,n) { int a; cin >> a; deq.push_back(a); } string s; cin >> s; rep(i,s.size()) { if (s[i]=='L') { int l1 = deq.front(); deq.pop_front(); int l2 = deq.front(); deq.pop_front(); deq.push_front(l1+l2); deq.push_back(0); } else { int r1 = deq.back(); deq.pop_back(); int r2 = deq.back(); deq.pop_back(); deq.push_back(r1+r2); deq.push_front(0); } } rep(i,n) { int ans = deq.front(); deq.pop_front(); cout << ans << " "; } cout << endl; }