#include #define _overload3(_1, _2, _3, name, ...) name #define _rep(i, n) repi(i, 0, n) #define repi(i, a, b) for (int i = (a); i < (b); ++i) #define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__) #define ALL(x) x.begin(), x.end() #define chmax(x, y) x = max(x, y) #define chmin(x, y) x = min(x, y) using namespace std; random_device rnd; mt19937 mt(rnd()); using ll = long long; using lld = long double; using VI = vector; using VVI = vector; using VL = vector; using VVL = vector; using PII = pair; const int IINF = 1 << 30; const ll INF = 1ll << 60; const ll MOD = 1000000007; int n, k; string s; int main() { int n, m; cin >> n >> m; deque que; rep(i, n) { int t; cin >> t; que.push_back(t); } string s; cin >> s; int tmp; for (const auto &c : s) { if (c == 'L') { tmp = que.front(); que.pop_front(); que.front() += tmp; que.push_back(0); } else { tmp = que.back(); que.pop_back(); que.back() += tmp; que.push_front(0); } } for (const auto &num : que) { cout << num << " "; } cout << endl; return 0; }