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]