while 1:s=raw_input();n=len(s);m=sorted(s[i:]+s[:i]for i in range(n));print m.index(s),''.join(m)[n-1::n]