P6388 [COCI 2007/2008 #4] LEKTIRA

Description

Given a string, split it into three parts, reverse each part, and then output them in the original order of the parts. Since there are multiple ways to split the string, output the lexicographically smallest possible result.

Input Format

One line containing a string, which is the string to be split.

Output Format

One line containing a string, which is the resulting string. It must be lexicographically smallest.

Explanation/Hint

#### Constraints For $100\%$ of the testdata, the length of the input string is guaranteed to be between $3\sim 50$. #### Notes **This problem is translated from [COCI2007-2008](https://hsin.hr/coci/archive/2007_2008/) [CONTEST #4](https://hsin.hr/coci/archive/2007_2008/contest4_tasks.pdf) *T3 LEKTIRA***。 Translated by ChatGPT 5