N,M=map(int, input().split()) A=list(map(int, input().split())) s=input() from collections import deque d=deque(A) for i in s: if i=='L': a=d.popleft() b=d.popleft() d.appendleft(a+b) d.append(0) else: a=d.pop() b=d.pop() d.appendleft(0) d.append(a+b) print(*d)