repeat l=io.read()p={l}for i=2,#l do p[i]=l:sub(i)..l end table.sort(p)s=" "for i=1,#l do p[p[i]]=i-1 s=s..p[i]:sub(#l,#l)end until print(p[l]..s)