#T318. 字符串匹配问题

字符串匹配问题

Description

The string contains only the following brackets: (), [], <>, {}. Determine whether the brackets in the input string are properly matched. If the brackets are nested, they must follow the order from innermost to outermost: <>, (), [], {}. For example:
Input: [()] → Output: YES,
Input: ([]) or ([)] → Output: NO.

Input Format

The first line contains an integer n, indicating the number of bracket strings to follow.
The next n lines each contain a bracket string with a length not exceeding 255.

Output Format

The output file should contain n lines, each being either YES or NO.

## Example

### Input:
3  
[()]  
([])  
([)]

### Output:
YES  
NO  
NO  
5
{}{}<><>()()\[\]\[\]
{{}}{{}}<<>><<>>(())(())\[\[\]\]\[\[\]\]
{{}}{{}}<<>><<>>(())(())\[\[\]\]\[\[\]\]
{<>}{\[\]}<<<>><<>>>((<>))(())\[\[(<>)\]\]\[\[\]\]
><}{{\[\]}<<<>><<>>>((<>))(())\[\[(<>)\]\]\[\[\]\]

YES
YES
YES
YES
NO