from collections import deque N, M = map(int, input().split()) A = deque(map(int, input().split())) S = input() lt = 0 rt = 0 for i in range(M): if S[i] == 'L': if lt == 0: if len(A) == 1: continue rt += 1 a = A.popleft() A[0] += a else: lt -= 1 rt += 1 else: if rt == 0: if len(A) == 1: continue lt += 1 a = A.pop() A[-1] += a else: lt += 1 rt -= 1 res = [0] * lt + list(A) + [0] * rt print(*res)