#include #include #include int main() { int N, M; std::cin >> N >> M; std::deque deq; for (int i = 0; i < N; i++) { int a; std::cin >> a; deq.push_back(a); } std::string S; std::cin >> S; for (char c : S) { if (c == 'L') { int a = deq.front(); deq.pop_front(); int b = deq.front(); deq.pop_front(); deq.push_front(a + b); deq.push_back(0); } else { int a = deq.back(); deq.pop_back(); int b = deq.back(); deq.pop_back(); deq.push_back(a + b); deq.push_front(0); } } std::cout << deq.front(); for (int i = 1; i < N; i++) std::cout << " " << deq[i]; std::cout << "\n"; }