#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; deque a; rep(i,N) { int x; cin >> x; a.push_back(x); } rep(i,M) { char c; cin >> c; if(c == 'L') { int x = a.front(); a.pop_front(); a.front() += x; a.push_back(0); } else { int x = a.back(); a.pop_back(); a.back() += x; a.push_front(0); } } for(int x : a) cout << x << " "; cout << "\n"; }