from collections import deque N,M = map(int,input().split()) A = deque(list(map(int,input().split()))) S = input() for i in S: if i == "L": a0 = A.popleft() a1 = A.popleft() A.appendleft(a0+a1) A.append(0) else: a0 = A.pop() a1 = A.pop() A.append(a0+a1) A.appendleft(0) print(*A)