from collections import deque n, m = map(int, input().split()) a = deque(map(int, input().split())) s = input() l = 0 r = n-1 for i in range(m): if s[i] == "L": if l - 1 < 0: if len(a) > 1: a0 = a.popleft() a1 = a.popleft() a.appendleft(a0+a1) else: l -= 1 r = max(r-1, 0) else: if r+1 > n-1: if len(a) > 1: a_1 = a.pop() a_2 = a.pop() a.append(a_1+a_2) else: r += 1 l = min(l+1, n-1) print(*[0]*l + list(a) + [0]*(n-1-r))