#include using namespace std; #define rep(i, n) for(int i = 0; i < int(n); i++) #define REP(i, n) for(int i = a; i < b; i++) using lint = long long; const lint MOD = 1e12; signed main(){ int n, m; cin >> n >> m; vector a(n); rep(i, n) cin >> a[i]; string s; cin >> s; deque que; rep(i, n) que.push_back(a[i]); rep(i, m){ if(s[i] == 'L'){ int x1 = que.front(); que.pop_front(); int x2 = que.front(); que.pop_front(); que.push_front(x1 + x2); que.push_back(0); } if(s[i] == 'R'){ int x1 = que.back(); que.pop_back(); int x2 = que.back(); que.pop_back(); que.push_front(0); que.push_back(x1 + x2); } } rep(i, n){ cout << que.front() << " "; que.pop_front(); } cout << endl; }