import sys, re from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import accumulate, permutations, combinations, product from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from bisect import bisect, bisect_left from fractions import gcd from heapq import heappush, heappop from functools import reduce def input(): return sys.stdin.readline().strip() def INT(): return int(input()) def MAP(): return map(int, input().split()) def LIST(): return list(map(int, input().split())) def ZIP(n): return zip(*(MAP() for _ in range(n))) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 N, M = MAP() a = LIST() S = input() L_index = 0 R_index = N-1 L_max = 0 R_max = 0 cnt = 0 for s in S: if s == "R": cnt += 1 if L_index < N-1: L_index += 1 if R_index < N-1: R_index += 1 elif s == "L": cnt -= 1 if 0 < L_index: L_index -= 1 if 0 < R_index: R_index -= 1 if L_max > cnt: L_max = cnt if R_max < cnt: R_max = cnt L_max = -L_max # print(L_index, R_index) if L_index == R_index: ans = [0]*N ans[L_index] = sum(a) print(*ans) exit() L_val = sum(a[:L_max+1]) R_val = sum(a[-R_max-1:]) # print(L_max, R_max, cnt) # print(L_val, R_val) ans = [0]*N for i, x in enumerate(a): if 0 < i-L_max and i+R_max < N-1: ans[i+cnt] = x elif i-L_max <= 0: ans[L_index] = L_val elif i+R_max >= N-1: ans[R_index] = R_val print(*ans)