import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines from collections import deque N, M = map(int, readline().split()) A = deque(map(int, readline().split())) S = read().rstrip().decode() L = 0 # A[0] の部屋 R = N - 1 # A[-1] の部屋 for s in S: if s == 'L': if L: L -= 1 R -= 1 else: if len(A) > 1: x = A.popleft() A[0] += x R -= 1 continue if R < N - 1: L += 1 R += 1 continue if len(A) == 1: continue x = A.pop() A[-1] += x L += 1 nums = [0] * N nums[L: R + 1] = A print(*nums)