#include using namespace std; typedef long long ll; #define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++) #define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++) #define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--) #define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) ((ll)(x).size()) #define len(x) ((ll)(x).length()) #define endl "\n" int main() { cin.tie(0); ios::sync_with_stdio(false); // ifstream in("input.txt"); // cin.rdbuf(in.rdbuf()); ll n, m; cin >> n >> m; deque a(n); rep(i, n) cin >> a[i]; string s; cin >> s; ll ls = 0, rs = 0; rep(i, m) { if (s[i] == 'L') { if (ls > 0) { ls--; rs++; } else { if (sz(a) > 1) { rs++; ll tmp = a[0] + a[1]; a.pop_front(); a.pop_front(); a.push_front(tmp); } else { if (ls > 0) { ls--; rs++; } } } } else { if (rs > 0) { rs--; ls++; } else { if (sz(a) > 1) { ls++; ll tmp = a[sz(a) - 1] + a[sz(a) - 2]; a.pop_back(); a.pop_back(); a.push_back(tmp); } else { if (rs > 0) { rs--; ls++; } } } } // printf("ls=%lld, rs=%lld\n", ls, rs); // rep(j, sz(a)) printf("%lld%s", a[j], (j == (sz(a) - 1)) ? "\n" : " "); } ll idx = 0; rep(i, n) { if (ls > 0) { ls--; printf("0"); } else if ((sz(a) - 1) >= idx) { printf("%lld", a[idx++]); } else { printf("0"); } printf("%s", (i == (n - 1)) ? "\n" : " "); } return 0; }