BWT by kt3k

while 1:a=raw_input();l=len(a);_=sorted(a[x:]+a[:x]for x in range(l));print _.index(a),`_`[l+1::l+4]

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

download

return top