#include using namespace std; int main() { int n, m; cin >> n >> m; vector a(n); for (int i = 0; i < n; i++) { cin >> a.at(i); } string s; cin >> s; int l = 0, r = n, lmerge = 0, rmerge = 0; for (int i = 0; i < m; i++) { if (s.at(i) == 'L') { l--; r--; if (l < 0) { l = 0; if (r > 0) { lmerge++; } else { r = 1; } } } else { l++; r++; if (r > n) { r = n; if (l < n) { rmerge++; } else { l = n - 1; } } } } for (int i = 0; i < lmerge; i++) { a.at(lmerge) += a.at(i); a.at(i) = 0; } for (int i = n - 1; i >= n - rmerge; i--) { a.at(n - 1 - rmerge) += a.at(i); a.at(i) = 0; } for (int i = 0; i < n; i++) { int iconvert = i - l + lmerge; if (iconvert >= 0 && iconvert < n) { cout << a.at(iconvert); } else { cout << 0; } if (i == n - 1) { cout << endl; } else { cout << " "; } } }