for(s=[];t=s[0]=readline(d=S="");){for(i=1;i<(l=s[0].length);i++)s[i]=s[i-1].slice(1)+s[i-1].charAt(0) s.sort() for(i=0;i