#include #include #include #include #define rep(i, a, n) for(int i = a; i < n; i++) using namespace std; using ll = long long; using P = pair; int main() { int n, m; cin >> n >> m; deque a(n); rep(i, 0, n){ cin >> a[i]; } string s; cin >> s; rep(i, 0, m){ if(s[i] == 'L'){ int temp = a[0] + a[1]; a.pop_front(); a.pop_front(); a.push_front(temp); a.push_back(0); } else{ int temp = a[n-1] + a[n-2]; a.pop_back(); a.pop_back(); a.push_back(temp); a.push_front(0); } } rep(i, 0, n){ cout << a[i] << " "; } cout << endl; return 0; }