logo AlgoBeat OnlineJudge
登录 注册

#207229. 「Wdcfr-1」Beautiful Array

内存限制:512 MiB 时间限制:100 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

In this problem, we define a sequence of ( and ) as a "bracket sequence".

The definition of Regular Bracket Sequence is as follows:

  1. () is a Regular Bracket Sequence.
  2. If A is a Regular Bracket Sequence, then (A) is also a Regular Bracket Sequence.
  3. If A and B are Regular Bracket Sequences, then AB is 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".

输入格式

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 .

输出格式

For each test case, print one line.

If it is possible to construct these arrays, print . Otherwise print .

样例

样例输入 1

2
2 1
()
2 99
()

样例输出 1

1
0

数据范围与提示

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

.