#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(false); int n, m; cin >> n >> m; deque a; rep(i, n){ ll x; cin >> x; a.push_back(x); } string s; cin >> s; rep(i, m){ if(s[i] == 'L'){ ll x = a.front(); a.pop_front(); x += a.front(); a.pop_front(); a.push_front(x); a.push_back(0); }else{ ll x = a.back(); a.pop_back(); x += a.back(); a.pop_back(); a.push_back(x); a.push_front(0); } } int cnt = 0; for(auto itr = a.begin(); itr != a.end(); itr++){ cout << *itr; cnt++; if(cnt < n) cout << " "; } cout << "\n"; }