#P7938. 「Wdcfr-1」Beautiful Array
「Wdcfr-1」Beautiful Array
Description
In this problem, we define a sequence of ( and ) as a "bracket sequence".
The definition of Regular Bracket Sequence is as follows:
()is a Regular Bracket Sequence.- If
Ais a Regular Bracket Sequence, then(A)is also a Regular Bracket Sequence. - If
AandBare Regular Bracket Sequences, thenABis also a Regular Bracket Sequence.
For example: (), (()), and ()() are all Regular Bracket Sequences, but )(, ()( are not.
In particular, an empty sequence is not a Regular Bracket Sequence sequence in this problem.
Now cute Ran gives you a bracket sequence of length . She wants you to construct strictly increasing arrays. Let us denote them as
(you can leave any of them empty). You need to ensure that all integers between appear exactly once in these arrays.
An array is Beautiful if is a Regular Bracket Sequence.
Ran wonders whether it is possible to construct these arrays so that at least of the arrays are "beautiful arrays".
Input Format
Each test contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case, the first line contains two integers and , and the second line contains a bracket sequence .
Output Format
For each test case, print one line.
If it is possible to construct these arrays, print . Otherwise print .
2
2 1
()
2 99
()
1
0
Hint
Explanation
For the first test case, we can construct and . So is a "beautiful array".
For the second test case, it is obvious that we cannot use two numbers to construct beautiful arrays.
Constraints
.
京公网安备 11011102002149号