HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Unsorted > problem:


Minimal Rotation

Section problems

• Number Spiral
• Two Sets
• Maximum Subarray Sum
• Ferris Wheel
• Distinct Numbers
• Dice Combinations
• Finding Periods
• Finding Borders
• Minimal Rotation
• Minimizing Coins
• Missing Coin Sum
• Playlist
• Concert Tickets
• Collecting Numbers
• Coin Combinations I
• Josephus Queries
• Money Sums

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 4000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb. Difficulty Alpha


A rotation of a string can be generated by moving characters one after another from beginning to end. For example, the rotations of acab are acab, caba, abac, and baca.

Your task is to determine the lexicographically minimal rotation of a string.

Input

The only input line contains a string of length n. Each character is one of a–z.

Output

Print the lexicographically minimal rotation.

Constraints
1≤n≤106

Example
Input:
acab

Output:
abac


Для отправки решений необходимо выполнить вход.

www.contester.ru