while 1:L=raw_input();S=sorted([L[i:]+L[:i]for i in range(len(L))]);print S.index(L),`S`[i+2::i+5]