#include<bits/stdc++.h> using namespace std; int main(){ int N,M,pos=0,length,R=1,L=1; cin >> N >> M; int a[N]; length=N; char opr; for(int i=0; i<N; i++){ cin >> a[i]; } cin >> opr; if(opr=='R'){ pos=1; R++; }else{ pos=0; L++; } length--; for(int i=1; i<M; i++){ cin >> opr; if(opr=='R'){ if(pos==N-length){ if(length>1){ length--; R++; pos++; } }else{ pos++; } }else{ if(pos==0){ if(length>1){ length--; L++; } }else{ pos--; } } } for(int i=0; i<L-1; i++){ a[L-1]+=a[i]; a[i]=0; } for(int i=N-1; i>N-R; i--){ a[N-R]+=a[i]; a[i]=0; } for(int i=0; i<pos; i++){ cout << 0 << " "; } for(int i=L-1; i<=N-R; i++){ cout << a[i] << " "; } for(int i=0; i<(N-length-pos); i++){ cout << 0 << " "; } return 0; }