while 1: l,*r=input().split(), while l:a,*l=l;k=int(a[1]);r+=[map(l.pop,[0]*k),r[-k:]]['R'