#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++) #define rep(i, n) repr(i, 0, n) #define INF 2e9 #define MOD 1000000007 //#define MOD 998244353 #define LINF (long long)4e18 #define jck 3.141592 #define PI acos(-1.0); const double EPS = 1e-10; using ll = long long; using Pi = pair; using Pl = pair; int main(){ int n,m; cin >> n >> m; vector a(n); rep(i,n) cin >> a[i]; string s; cin >> s; int ok = 0,ng = n; while(ng-ok > 1){ int mid = (ok+ng)/2; int now = mid; rep(i,m){ if(s[i] == 'L') now = max(0,now-1); else now = min(n-1,now+1); if(now == 0){ ok = mid; break; } } if(ok != mid) ng = mid; } int ok2 = n-1, ng2 = -1; while(ok2-ng2 > 1){ int mid = (ok2+ng2)/2; int now = mid; rep(i,m){ if(s[i] == 'L') now = max(0,now-1); else now = min(n-1,now+1); if(now == n-1){ ok2 = mid; break; } } if(ok2 != mid) ng2 = mid; } int now0 = 0; rep(i,m){ if(s[i] == 'L') now0 = max(0,now0-1); else now0 = min(n-1,now0+1); } int nown = n-1; rep(i,m){ if(s[i] == 'L') nown = max(0,nown-1); else nown = min(n-1,nown+1); } int last = 0; rep(i,m){ if(s[i] == 'L') last--; else last++; } vector ans(n); rep(i,n){ if(i <= ok){ ans[now0] += a[i]; } else if(i < ok2){ ans[i+last] += a[i]; } else ans[nown] += a[i]; } rep(i,n) cout << ans[i] << " "; cout << endl; }