Prefix reversal#1718

Prefix reversal

1 second
64 megabytes
Easy

In the Laboratory of Intelligent Prefix Algorithms (LIPA), they are testing a Prefix-Reversing Machine (PRM). The machine works as follows: it receives as input a string of length and a sequence 1 \leq a_1 < a_2 < \ldots < a_k \leq n. Initially, the string is placed into a special internal register of the machine. Then, for each from to , the machine takes the prefix [1..a_i] of the current string and reverses it. The string that remains in the register after the machine finishes is the result of the machine.

For example, if the input string is and the sequence is a_1 = 2, a_2 = 4, the output will be the string .

The scientists at LIPA want to find, for a given string, such a sequence so that the resulting string is as small as possible in lexicographical order. A string \alpha = \alpha_1\alpha_2 \ldots \alpha_n is lexicographically smaller than a string \beta = \beta_1\beta_2 \ldots \beta_m if, for some , for all 1 \leq t \leq k it holds that \alpha_t = \beta_t, and either \alpha_{k+1} < \beta_{k+1}, or the length of is and the length of is greater than .

Help them determine the lexicographically smallest result that can be obtained.

Input

The input file contains the string (it is nonempty and its length does not exceed ). It consists of lowercase English letters.

Output

Print the lexicographically smallest string that can be obtained by the PRM on input string .

Examples

Example 1

Loading
Loading