BWT by kaki

for(s=[];t=s[0]=readline(d=S="");){for(i=1;i<(l=s[0].length);i++)s[i]=s[i-1].slice(1)+s[i-1].charAt(0)\x0ds.sort()\x0dfor(i=0;i<l;S+=s[i].charAt(l-1),i++)if(t==s[i]&&d==="")d=i\x0dprint(d+" "+S)}

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return top