e,r,p;char*b,a[99],*d[99],*s="R4R3R2R1L0L1L2L3L4";main(h){for(;gets(a);puts(""),p=0)for(h=1;b=strtok(b?0:a," ");)if(e)h=!printf(" %s"+h,d[p++]=b,--e);else for(e=(strstr(s,b)-s)/2-4,r=p;e<0;)printf(" %s"+h,d[p++]=d[r+e++]);}