Problem7638--[CSES Problem Set] Minimal Rotation

7638: [CSES Problem Set] Minimal Rotation

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 256 MiB

Description

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≤10^6$

Sample 1 Input

acab

Sample 1 Output

abac

HINT

相同题目:CSES 1110

Source/Category