#include using namespace std; #ifdef LOCAL #include "debug.h" #else #define DEBUG(...) #endif int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n, m; cin >> n >> m; deque deq(n); for (auto&& e : deq) { cin >> e; } string s; cin >> s; for (char c : s) { if (c == 'L') { deq[1] += deq[0]; deq.pop_front(); deq.push_back(0); } else { deq[n - 2] += deq[n - 1]; deq.pop_back(); deq.push_front(0); } } for (int i = 0; i < n; ++i) { cout << deq[i] << " \n"[i == n - 1]; } }