Statement
You are given a parenthesis string of length . Flipping the -th character costs . A flip changes ( to ) and ) to (.
A string is called a regular bracket sequence if it can be defined by the following rules.
- The empty string is a regular bracket sequence.
- If is a regular bracket sequence, then is also a regular bracket sequence.
- If and are regular bracket sequences, then is also a regular bracket sequence.
Only strings that can be obtained by applying the above rules a finite number of times are regular bracket sequences.
Flip some characters of to make it a correct parenthesis string. Print the minimum possible cost and one resulting string attaining that cost.
Input
The input is given from Standard Input in the following format:
Each case is given in the following format:
Output
For each test case, first print the minimum cost on one line.
On the next line, print any correct parenthesis string obtainable with that minimum cost.
Constraints
- .
- .
- has length and consists only of
(and). - ().
- The sum of over all test cases does not exceed .
Subtasks
Samples
In the first test case, flipping the second character changes the string to at a cost of . It is impossible to obtain a valid parenthesis string at cost , so the minimum cost is .