#include #include #include #include #include #include #include using namespace std; typedef long long ll; int N, M; int a[200000]; int fin[200000]; int ans[200000]; string S; int sim(int s){ for(int i = 0; i < M; i++){ if(S[i] == 'L') s = max(s-1, 1); else s = min(s+1, N); } return s; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; cin >> N >> M; for(int i = 0; i < N; i++) cin >> a[i]; cin >> S; int l = 0, r = 0; int sum = 0; for(int i = 0; i < M; i++){ if(S[i] == 'L') sum--; else sum++; l = min(l, sum); r = max(r, sum); } // cout << sum << ' ' << l << ' ' << r << endl; fin[0] = sim(1); fin[N-1] = sim(N); // cout << fin[0] << ' ' << fin[N-1] << endl; if(fin[0] == fin[N-1]){ for(int i = 0; i < N; i++) ans[fin[0]-1] += a[i]; }else{ for(int i = 0; i < N; i++){ if(i+1+l <= 1) ans[fin[0]-1] += a[i]; else if(i+r+1 >= N) ans[fin[N-1]-1] += a[i]; else ans[i+sum] += a[i]; } } for(int i = 0; i < N; i++) cout << ans[i] << ' '; cout << endl; }