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