#include using namespace std; typedef long long ll; using vll = vector; using vi = vector; using vvi = vector>; using vb = vector; using pii = pair; template inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } //pow(llpow,modpow) template ll llpow(ll x, T n) { ll ans = 1; if (x == 0) ans = 0; while (n) { if (n & 1) ans *= x; x *= x; n >>= 1; } return ans; } long long modpow(long long a, long long n, long long mod) { long long res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1; } return res; } //最大公約数 template inline T gcd(T x, T y) { if (y == 0) return x; else { return gcd(y, x % y); } } //最小公倍数 template inline T lcm(T x, T y) { return x / gcd(x, y) * y; } //逆元 long long modinv(long long a, long long m) { long long b = m, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u; } #define rep(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++) long long INF = 1LL << 60; int main() { int n, m; cin >> n >> m; vll a(n); rep(i, 0, n) cin >> a[i]; string s; cin >> s; //配列上 int rl = 0, rr = n - 1; //論理的 int l = 0, r = n - 1; rep(i, 0, s.size()) { if (s[i] == 'L') { if (abs(r - l) >= 1) { if (l == 0) { r--; a[rl + 1]+= a[rl]; a[rl] = 0; rl++; } else { r--; l--; } } else { if (l == 0) continue; else { r--; l--; } } } else { if (abs(r - l) >= 1) { if (r == (n - 1)) { l++; a[rr - 1]+= a[rr]; a[rr] = 0; rr--; } else { r++; l++; } } else { if (r == n - 1) continue; else { r++; l++; } } } } vll ans(n,0); rep(i,0,n){ if(i>=l&&i<=r){ ans[i]=a[rl+(i-l)]; } else{ ans[i]=0; } cout<