Decomposition#493

Decomposition

1 second
64 megabytes
Easy

Consider a sequence consisting of and . Consider all its cyclic shifts. That is, write the characters of the sequence in a circle and read its symbols clockwise, starting from any position, until you return to the starting character. For example, for , the following options exist in lexicographical order: , , , , . If the sequence coincides with the first option after sorting these cyclic shifts, we will call it a "necklace". Thus, is a "necklace", while is not.

Any sequence can be uniquely written as a concatenation of necklaces T_i: S = T_1 T_2 \ldots T_k, such that T_i T_{i+1} is not a necklace, and T_{i+1} < T_i for all from to k-1. The relation A < B means that either the first symbols of match those of and |A| < |B|, or the first symbols of coincide with the first symbols of , and the (m+1)-th symbol of is less than the (m+1)-th symbol of . For example, 001 < 0010 and 1101011 < 110110. Write a program that, for a given string, finds its representation as a concatenation of necklaces.

Input

Input consists of a single string of length at most , containing only and .

Output

Output the representation of the input string as described above. Each "necklace" should be enclosed in parentheses.

Examples

Example 1

Loading
Loading