#include using namespace std; enum pos { L, M, R }; int main() { int N, M; cin >> N >> M; vector A(N); for(auto &e : A) cin >> e; string S; cin >> S; auto side = [&](int x) -> int { if(x == 0) return pos::L; if(x == N - 1) return pos::R; for(auto &c : S) { if(c == 'L') x--; else x++; if(x == 0) return pos::L; if(x == N - 1) return pos::R; } return pos::M; }; int L, R; int l = 0, r = N; while(r - l > 1) { int c = (l + r) / 2; if(side(c) == pos::L) l = c; else r = c; } L = l; l = -1, r = N - 1; while(r - l > 1) { int c = (l + r) / 2; if(side(c) == pos::R) r = c; else l = c; } R = r; auto end = [&](int x) -> int { for(auto &c : S) { if(c == 'L') x = max(0, x - 1); else x = min(N - 1, x + 1); } return x; }; vector ans(N); int a = end(L), b = end(R); for(int i = L; i >= 0; --i) ans[a] += A[i]; for(int i = L + 1; i < R; ++i) ans[++a] = A[i]; for(int i = R; i < N; ++i) ans[b] += A[i]; for(int i = 0; i < N; ++i) cout << ans[i] << " "; cout << '\n'; return 0; }