#include using namespace std; #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define llong long long int main() { int n, m; cin >> n >> m; vector a(n); rep(i, n) cin >> a[i]; string s; cin >> s; int minval = 0; int minpos = 0; int maxval = 0; int maxpos = 0; int total = 0; rep(i, s.length()) { bool left = s[i] == 'L'; if(left) { total -= 1; if(minval > total) { minval = total; minpos = i; } } else { total += 1; if(maxval < total) { maxval = total; maxpos = i; } } } vector result(n, 0); rep(i, n) { if(minval + i < 0) { if(maxval + i >= n) { if(minpos < maxpos) { result[n - 1 - (maxval - total)] += a[i]; } else { result[0 + (total - minval)] += a[i]; } } else { result[0 + (total - minval)] += a[i]; } } else { if(maxval + i >= n) { result[n - 1 - (maxval - total)] += a[i]; } else { result[i + total] += a[i]; } } } rep(i, n) { cout << result[i]; if(i < n-1) cout << " "; } cout << "\n"; }