#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define llint long long #define inf 1e18 #define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++) #define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) using namespace std; typedef pair P; llint n, m; llint a[200005], sum[200005]; string s; int main(void) { ios::sync_with_stdio(0); cin.tie(0); cin >> n >> m; for(int i = 1; i <= n; i++) cin >> a[i]; cin >> s; for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i]; llint l = 1, r = n, L = 1, R = n; for(int i = 0; i < s.size(); i++){ if(l == r){ if(s[i] == 'L'){ if(l > 1) l--, r--; } else{ if(r < n) l++, r++; } continue; } if(s[i] == 'L'){ if(l > 1) l--, r--; else L++, r--; } else{ if(r < n) l++, r++; else R--, l++; } } //cout << l << " " << r << endl; for(int i = 1; i <= n; i++){ if(i < l || i > r){ cout << 0 << " "; continue; } if(i == l) cout << sum[L] << " "; else if(i == r) cout << sum[n]-sum[R-1] << " "; else cout << a[(i-l)+L] << " "; } cout << endl; return 0; }