import sys from collections import deque n, m = map(int, sys.stdin.readline().split()) a = deque(map(int, sys.stdin.readline().split())) s = sys.stdin.readline().rstrip() def main(): l = r = 0 for c in s: if c == 'L': if l == 0: if len(a) == 1: continue b = a.popleft() a[0] += b r += 1 l = max(0, l - 1) else: if r == 0: if len(a) == 0: continue b = a.pop() a[-1] += b r = max(0, r - 1) l += 1 if len(a) == 1: break res = [0] * l + list(a) + [0] * r print(*res, sep=' ') if __name__ == '__main__': main()