BWT by 7gyou

import java.util.*;class T{public static void main(String[]a){try{for(;;){TreeSet t=new TreeSet();String z="",y,x=new java.io.DataInputStream(System.in).readLine();int r=x.length(),i=0,f=r+1;for(;i<r;)t.add(x.substring(i++)+x);for(i=0;i<r;i++){y=(String)t.toArray()[i];if(f>r&y.indexOf(x)==0)f=i;z+=y.charAt(r-1);}System.out.println(f+" "+z);}}catch(Exception e){}}}

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

download

return to the top page