#P2164. 字符串排序

字符串排序

给出一个长为len的字符串str,把字符串的首尾相连,然后以每个字符为起点,顺时针遍历每个字符,得到len个新的字符串,然后把这len个字符串按照字典序从小到大的顺序进行排序,取出排完序后的每个字符串的最后一个字符,形成一个新的字符串S。求S。
如下图。假设str=“topcoder”,则得到的新的字符串有
topcoder, opcodert, pcoderto, codertop, odertopc, dertopco, ertopcod, rtopcode,按字典序排完序为
codertop, dertopco, ertopcod, odertopc, opcodert, pcoderto, rtopcode, topcoder,
则取出每个字符串最后一个字符之后形成的字符串为podctoer,即S = “podctoer”。

Input

多组测试数据。
每组测试数据包括一个字符串,长度不超过100000。字符串由所有可打印字符组成。

Output

每组数据占一行,输出S。

Sample Input

topcoder
I LOVE YOU

Sample Output

podctoer
IEVU YLOO 

HINT

Source