#include #include #include #define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i) #define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; template inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;} template inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;} int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector A(N); for (auto& a : A) { cin >> a; } string S; cin >> S; int l = 0, r = N - 1; int l_cnt = 0, r_cnt = 0; rep(i, 0, M) { if (S[i] == 'L' && r_cnt < N - 1) { ++r_cnt; if (l_cnt) { --l_cnt; } else { A[l + 1] += A[l]; ++l; } } else if (S[i] == 'R' && l_cnt < N - 1) { ++l_cnt; if (r_cnt) { --r_cnt; } else { A[r - 1] += A[r]; --r; } } } rep(i, 0, l_cnt) { cout << 0 << ' '; } rep(i, l, r + 1) { cout << A[i] << ' '; } rep(i, 0, r_cnt) { cout << 0 << ' '; } cout << endl; return 0; }