BWT by zetamatta

while 1:L=raw_input();R=range(len(L));S=sorted(L[i:]+L[:i]for i in R);print[i for i in R if S[i]==L][0],"".join(i[-1:]for i in S)

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

download

return top