N,M = map(int, input().split()) A = [int(a) for a in input().split()] S = input() from collections import deque q = deque(A) for i in range(M): if S[i] == "L": t1 = q.popleft() t2 = q.popleft() q.appendleft(t1+t2) q.append(0) else: t1 = q.pop() t2 = q.pop() q.append(t1+t2) q.appendleft(0) print(*list(q))