def main(): import sys from collections import deque input = sys.stdin.readline N, M = map(int, input().split()) A = deque(list(map(int, input().split()))) S = input().rstrip('\n') for s in S: if s == 'R': a1 = A.pop() a2 = A.pop() A.append(a1+a2) A.appendleft(0) else: a1 = A.popleft() a2 = A.popleft() A.appendleft(a1 + a2) A.append(0) print(*A) if __name__ == '__main__': main()