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