#include int ri() { int n; scanf("%d", &n); return n; } int main() { int n = ri(); int m = ri(); int a[n]; for (auto &i : a) i = ri(); std::string s; std::cin >> s; int left_clear = 0; int right_clear = 0; std::deque all(a, a + n); for (int i = 0; i < m; i++) { if (s[i] == 'R') { if (right_clear) right_clear--; else if (all.size() > 1) all[all.size() - 2] += all.back(), all.pop_back(); if (left_clear + 1 < n) left_clear++; } else { if (left_clear) left_clear--; else if (all.size() > 1) all[1] += all[0], all.pop_front(); if (right_clear + 1 < n) right_clear++; } } for (int i = 0; i < left_clear; i++) all.push_front(0); all.resize(n); for (int i = 0; i < n; i++) printf("%d ", all[i]); puts(""); return 0; }