#include #include #include #include #define rep(i, n) for(i = 0; i < n; i++) using namespace std; int n, m; int a[200000]; string s; int main() { int i; cin >> n >> m; rep(i, n) cin >> a[i]; cin >> s; int pos = 0; int minP = 0, maxP = 0; rep(i, m) { if (s[i] == 'L') pos--; else pos++; minP = min(minP, pos); maxP = max(maxP, pos); } int l = -minP; int r = n - 1 - maxP; l = min(l, n - 1); r = max(l, r); pos = 0; rep(i, m) { if (s[i] == 'L') pos = max(0, pos - 1); else pos = min(n - 1, pos + 1); } vector ans; for (i = 0; i < pos; i++) ans.push_back(0); for (i = pos; i <= pos + r - l; i++) { if (i == pos) { int sumA = 0; for (int j = 0; j <= l; j++) sumA += a[j]; ans.push_back(sumA); } else if (i == pos + r - 1) { int sumA = 0; for (int j = r; j < n; j++) sumA += a[j]; ans.push_back(sumA); } else { ans.push_back(a[i + pos - l]); } } for (i = pos + r - l + 1; i < n; i++) ans.push_back(0); rep(i, ans.size()) { cout << ans[i]; if (i + 1 < ans.size()) cout << " "; } cout << endl; return 0; }