from collections import deque n,m=map(int,input().split()) a=list(map(int,input().split())) s=input() q=deque() for i in a: q.append(i) for i in s: if i=='L': out1=q.popleft() out2=q.popleft() q.appendleft(out1+out2) q.append(0) else: out1=q.pop() out2=q.pop() q.append(out1+out2) q.appendleft(0) print(*q)