#include #include #include #include #include #include #include #include #include #include #include #include #include #define FOR(i, n, m) for(ll i = n; i < (int)m; i++) #define REP(i, n) FOR(i, 0, n) #define ALL(v) v.begin(), v.end() #define pb push_back using namespace std; using ll = long long; using P = pair; constexpr ll inf = 1000000000; constexpr ll mod = 998244353; constexpr long double eps = 1e-9; int main() { cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector a(n); REP(i, n) cin >> a[i]; string s; cin >> s; vector l, r; l.pb(1); r.pb(n); int lp = 1, rp = n; REP(i, m) { if(lp == rp) { if(s[i] == 'L') { if(lp != 1) { lp--; rp--; } } else { if(lp != n) { lp++; rp++; } } continue; } if(s[i] == 'L') { if(lp == 1) { l.pb(l.back() + 1); rp--; } else { lp--; rp--; } } else { if(rp == n) { r.pb(r.back() - 1); lp++; } else { lp++; rp++; } } } vector ans(n, 0); for(int i = lp; i <= rp; i++) { if(i == lp) { REP(j, l.size()) ans[i - 1] += a[l[j] - 1]; } else if(i == rp) { REP(j, r.size()) ans[i - 1] += a[r[j] - 1]; } else { ans[i - 1] = a[(int)l.size() + (i - lp) - 1]; } } REP(i, n) { if(i) cout << " "; cout << ans[i]; } cout << endl; return 0; }