Magic Towers#5442

Magic Towers

5 seconds
64 megabytes
Easy

Given a number and a sequence of numbers, you are required to examine all possible cyclic shifts of the sequence, sort them in lexicographical order, and output them according to this order. If two different cyclic shifts are equal, the one that starts further to the left is considered smaller.

Input

The input consists of no more than test cases. Each test case consists of two lines. The first line contains an integer 1 \leq n \leq 50000, the length of the sequence. The second line contains numbers in the range from to , which represent the given sequence. The input is terminated by a line containing the number instead of .

Output

For each test case, output all cyclic shifts, one per line, sorted in lexicographical order.

Examples

Example 1

Loading
Loading