n, m = map(int, input().split()) a = list(map(int, input().split())) s = input() rmax = 0 lmax = 0 now = 0 for i in s: if i == "L": now -= 1 else: now += 1 rmax = max(rmax, now) lmax = max(lmax, -now) now = max(0, now) now = min(n-1, now) ans = [0] * n if rmax + lmax >= n - 1: ans[now] = sum(a) else: for i in range(lmax): a[lmax] += a[i] a[i] = 0 for i in range(rmax): a[n-1-rmax] += a[n-1-i] a[n-1-i] = 0 for i in range(now, n): ans[i] = a[i-now] print(*ans)