n,m=map(int,input().split()) a=[int(j) for j in input().split()] s=input() l,r=0,0 p,q,tmp=0,0,0 for i in s: if i=="L": r=min(n-1,r+1) l=max(0,l-1) tmp-=1 p=max(p,-tmp) else: l=min(n-1,l+1) r=max(0,r-1) tmp+=1 q=max(q,tmp) if p+q>=n: ans=[0]*l+[sum(a)]+[0]*r else: ans=[0]*l+[sum(a[:p+1])]+a[p+1:-q-1]+[sum(a[-q-1:])]+[0]*r print(*ans)