#P10161. [DTCPC 2024] 小方的疑惑 10
[DTCPC 2024] 小方的疑惑 10
Background
Xiaofang always has many doubts.
Problem Description
On Little C's birthday a few years ago, he received a gift: a string of length consisting only of and , in which exactly substrings are valid bracket sequences.
Since Xiaofang is very curious about what this gift looks like, you need to construct such a string, or output to indicate that there is no solution.
A valid bracket sequence satisfies the following conditions:
- is a valid bracket sequence.
- If and are valid bracket sequences, then and are valid bracket sequences.
- All other sequences are not valid bracket sequences.
Xiaofang has many doubts, so he will ask you times.
Input Format
The first line contains an integer representing the number of queries.
The next lines each contain two integers and (, ).
The input and output size of this problem is large, so please use fast I/O.
Output Format
For each query, if a solution exists, output a string of length on one line; otherwise output .
3
5 2
5 3
5 4
(())(
()()(
-1
Hint
Translated by ChatGPT 5