#define _USE_MATH_DEFINES #include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define MT make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)<; using vi = vector; using vll = vector; void solve() { int N, M; cin >> N >> M; deque A(N); each(a, A)cin >> a; string S; cin >> S; each(c, S) { if (c == 'L') { int x = A[0]; A.pop_front(); A.push_back(0); A[0] += x; } else { int x = A.back(); A.pop_back(); A.push_front(0); A.back() += x; } } rep(i, N) cout << A[i] << (i != N - 1 ? ' ' : '\n'); } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }