#include #include #include #define rep(i, n) for(int (i) = (0); (i) < (n); (i)++) using namespace std; int main(){ int m, n, j; int tmp; cin >> n >> m; deque a(n, 0); rep(i, n) cin >> a[i]; string s; cin >> s; rep(i, m){ if(s[i] == 'L'){ tmp = a.front(); a.pop_front(); tmp += a.front(); a.pop_front(); a.push_front(tmp); a.push_back(0); } else{ tmp = a.back(); a.pop_back(); tmp += a.back(); a.pop_back(); a.push_back(tmp); a.push_front(0); } } rep(i, n) cout << a[i] << ' '; cout << endl; return 0; }