Problem1635--Necklace Decomposition

1635: Necklace Decomposition

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 0
[Submit] [Status] [Web Board] [Creator:]

Description

Input

On the first line of the input is a single positive integer n, telling the number of test scenarios to follow. Each scenario consists of one line containing a non-empty string of zeros and ones of length at most 100.

Output

For each scenario, output one line containing the necklace decomposition of the string. The necklaces should be written as '(' necklace ')'.

Sample Input Copy

5
0
0101
0001
0010
11101111011

Sample Output Copy

(0)
(0101)
(0001)
(001)(0)
(111)(01111)(011)

Source/Category

92