#include #define REP(i, n) for (int i = 0; i < n; i++) #define REPR(i, n) for (int i = n; i >= 0; i--) #define FOR(i, m, n) for (int i = m; i < n; i++) #define ALL(v) v.begin(), v.end() using namespace std; typedef long long ll; typedef long double ld; int main() { int n,m; cin >> n >> m; deque que; REP(i,n){ int a; cin >> a; que.push_back(a); } string s; cin >> s; REP(i,m){ if(s[i]=='L'){ int a1 = que.front(); que.pop_front(); int a2 = que.front(); que.pop_front(); que.push_front(a1+a2); que.push_back(0); }else{ int a1 = que.back(); que.pop_back(); int a2 = que.back(); que.pop_back(); que.push_back(a1+a2); que.push_front(0); } } REP(i,n) cout << que[i] << " "; cout << '\n'; return 0; }