시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 2048 MB72228.571%

문제

You are given a string $s$ consisting of parentheses ("(" and ")") and digits ("0" through "9"). From the string $s$, you construct another string $t$ by considering every character of $s$ in order and performing the following operations based on the character values:

  • "(": append "(" to $t$.
  • ")": append ")" to $t$.
  • $0 \leq c \leq 9$: delete any $c$ characters from $t$. It is guaranteed that it is always possible to do so. The deleted characters don't need to be consecutive.

Is it possible to construct $t$ to be a balanced bracket sequence?

입력

The first line contains an integer $t$ ($1 \leq t \leq 10^{4}$), the number of test cases.

For each test case, you are given a non-empty string $s$ consisting of parentheses and digits ("()0123456789"). The length of the string will be at most $3 \cdot 10^{5}$ characters.

It is guaranteed that the total length of the strings will not exceed $3 \cdot 10^{5}$ characters.

출력

For each test case, output "YES" if it is possible to construct $t$ to be a balanced bracket sequence, and "NO" otherwise.

You may output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

예제 입력 1

2
((()(3)1
(()1)

예제 출력 1

Yes
No

예제 입력 2

5
()1()
(())
()1((((2()())))3)()
((2))()
((1()))(1)()

예제 출력 2

No
Yes
Yes
No
Yes