#include #define rep(i,n) for (int i=0; i<(int)(n); i++) #define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++) using namespace std; using ll = long long; using P = pair; int main() { int n; cin >> n; int m; cin >> m; deque a; rep(i,n) { int ai; cin >> ai; a.push_back(ai); } string s; cin >> s; rep(i,m) { int t = 0; if (s[i] == 'L') { t += a.front(); a.pop_front(); t += a.front(); a.pop_front(); a.push_front(t); a.push_back(0); } else if(s[i] == 'R') { t += a.back(); a.pop_back(); t += a.back(); a.pop_back(); a.push_back(t); a.push_front(0); } } rep(i,n) { cout << a[i]; if (i==n-1) cout << endl; else cout << " "; } }