n,m = map(int,input().split()) a = list(map(int,input().split())) s = input() # [l, r] l,r = 0,n-1 l_margin = 0 r_margin = 0 for com in s: if l == r: if com == 'L': if l_margin: l_margin -= 1 r_margin += 1 else: if r_margin: r_margin -= 1 l_margin += 1 continue if com == 'L': if l_margin: l_margin -= 1 r_margin += 1 continue if l + 1 >= n: continue a[l + 1] += a[l] a[l] = 0 l += 1 r_margin += 1 else: if r_margin: r_margin -= 1 l_margin += 1 continue if r - 1 < 0: continue a[r - 1] += a[r] a[r] = 0 r -= 1 l_margin += 1 # print(a, l, r, l_margin, r_margin) res = [0] * l_margin res += a[l:r+1] res += [0] * r_margin print(*res) # print(l, r)