A cyclic shift of a string is a string obtained by moving some of the initial characters of the original string to its end. Your task is to find the lexicographically smallest cyclic shift of a given string.
The first line contains the integer — the number of test cases. The next lines each contain a string. Each string consists of characters with ASCII codes from to . The size of the input file does not exceed one megabyte.
For each test case, output a single line containing the smallest cyclic shift.
Example 1