while 1: c,l=input(),"" while c:s,f=int(c[1])*3,c<"R";l+=[l[-s:],c[2:s+2]][f];c=c[f*s+3:] print(l[1:])