Programmer's school

Forgot password?
[problems] [status] [courses] [info] [register]
Login:   Password:    

Minimal Shift

(Time limit: 1 sec. Memory limit: 16 MB Difficulty: 61%)

A cyclic shift of the string s is the string sk+1sk+2…sns1s2…sk for some k (0 ≤ k < n) where n is the length of the string s.

For a given string, find out its lexicographically minimal shift, i.e., among all possible cyclic shifts of the string find one that is the first in alphabetical order.

Input

The only line of input contains a string consisting of characters with ASCII codes 33 to 127. A string length can be up to 105.

Output

Output one line - the minimal lexicographic shift of the input string.

Samples

INPUT.TXTOUTPUT.TXT
1programamprogr
2cababc
3bbbbbbbbbb

Для отправки решения задачи необходимо зарегистрироваться и авторизоваться!


 C++ programming language
 Solution of olympiad tasks
 Regional competition
 Books by Fyodor Menshikov
 USE in informatics
 Training olympics
 Introduction
 Integer arithmetic
 Sorting algorithms
 Long arithmetic
 C++ Standard Template Library
 Dynamic programming
 Combinatorics
 Computational geometry
 String
 Data structures
 Graph theory - 1
 Graph theory - 2
 Simple tasks
 Algorithms on strings
 Polynomial hash
 A. Funktsiya Eylera
 B. Obratnyy element
 C. Hesh-funktsiya
 D. Vzlom hesh-funktsii
 E. Reklamnyy shchit
 F. Minimalnyy sdvig
 G. Slova
 H. Stroki - 3
 I. Podpalindromy
 J. Tsiklicheskie sdvigi

Krasnoyarsk regional Palace of pioneers, (c)2006 - 2025, ИНН 246305493507, E-mail: admin@acmp.ru