import std.stdio, std.array, std.string, std.conv, std.algorithm; import std.typecons, std.range, std.random, std.math, std.container; import std.numeric, std.bigint, core.bitop, core.stdc.stdlib; void main() { auto s = readln.split.map!(to!int); auto N = s[0]; auto M = s[1]; auto A = readln.split.map!(to!long).array; auto S = readln.chomp; int left = 0; int right = N - 1; int left_end = 0; int right_end = N - 1; int diff = 0; foreach (c; S) { if (c == 'L') { if (left_end == 0) { left = min(N - 1, left + 1); right_end = max(0, right_end - 1); } else { left_end = max(0, left_end - 1); right_end = max(0, right_end - 1); } diff -= 1; } else { if (right_end == 0) { right = max(0, right - 1); left_end = min(N - 1, left_end + 1); } else { left_end = min(N - 1, left_end + 1); right_end = min(N - 1, right_end + 1); } diff += 1; } } auto ans = new long[](N); foreach (i; 0..N) { if (i <= left) { ans[left_end] += A[i]; } else if (i >= right) { ans[right_end] += A[i]; } else { ans[i + diff] += A[i]; } } ans.map!(to!string).join(" ").writeln; }