Problem 1214 --Magic brackets## 1214: Magic brackets

Time Limit: 1 Sec Memory Limit: 128 MB

Submit: 568 Solved: 232

[Submit][Status][Web Board]## Description

IceRuler likes Brackets. He has n brackets sequences. And you should tell him whether they are matched.
The brackets will only contain {, }, (, ), [, ]. The matching rules are the same as in Math.

## Input

The first line is integer T, the number of test cases. (1 <= T <= 20) For each test case, there is an integer n in one line(1 <= n <= 30000) and n lines means n brackets sequences.

## Output

For each brackets sequences, print "YES" if it is matched. Otherwise, print "NO".

## Sample Input

7
1
(
2
()
2
{]
6
[(){}]
4
(])[
8
[[{{}}]]
6
[][{]]

## Sample Output

NO
YES
NO
YES
NO
YES
NO

## HINT

## Source

[Submit][Status]