#include using namespace std; using ll=long long; using vll=vector; int main() { ll N,K,T; cin>>N>>K>>T; T%=(2*K); vll B(N),G(N); vector A(N); for(ll i=0;i>A[i]; } vector> P(N); for(ll i=0;i>B[i]; P[i]={B[i],i}; ll ZT=T; if(A[i]=='B'){ if(K-B[i]>=ZT){ G[i]=B[i]+ZT; continue; } ZT-=(K-B[i]); B[i]=K; if(B[i]>ZT){ G[i]=B[i]-ZT; continue; } ZT-=B[i]; B[i]=0; G[i]=ZT; } else{ if(B[i]>ZT){ G[i]=B[i]-ZT; continue; } ZT-=B[i]; B[i]=0; if(ZT<=K){ G[i]=ZT; continue; } ZT-=K; G[i]=K-ZT; } } sort(P.begin(),P.end()); sort(G.begin(),G.end()); vector AN(N); for(ll i=0;i