#define _USE_MATH_DEFINES #include using namespace std; signed main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; deque a; for (int i = 0; i < n; i++) { int x; cin >> x; a.push_back(x); } string s; cin >> s; for (char c : s) { if (c == 'L') { int x = a.front(); a.pop_front(); a.front() += x; a.push_back(0); } else { int x = a.back(); a.pop_back(); a.back() += x; a.push_front(0); } } for (int i = 0; i < n; i++) { if (i > 0) cout << " "; cout << a[i]; } cout << endl; return 0; }