import algorithm, math, sequtils, strutils, macros let read* = iterator: string {.closure.} = while true: (for s in stdin.readLine.split: yield s) template input*(T: static[typedesc]): untyped = when T is int: read().parseInt elif T is float: read().parseFloat elif T is string: read() let N, M = input(int) var A = @[0] & newSeqWith(N, input(int)) let S = input(string) var lmax, rmax, now = 0 for c in S: case c of 'L': if now > -(N - 1): now -= 1 lmax = max(lmax, -now) of 'R': if now < N - 1: now += 1 rmax = max(rmax, now) else: discard for i in 1 .. lmax: A[i + 1] += A[i] A[i] = 0 for i in 1 .. rmax: A[^(i + 1)] += A[^i] A[^i] = 0 if now == 0: echo A[1 .. N].mapIt($it).join(" ") elif now < 0: let L = -now echo (A[L + 1 .. N] & 0.repeat(L)).mapIt($it).join(" ") else: let R = now echo (0.repeat(R) & A[1 .. ^(R + 1)]).mapIt($it).join(" ")