3037 - 2024_DS_Summer_Lab5 Scoreboard

Time

2024/07/10 13:00:00 2024/08/02 13:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14227 2024_IDS_Spring_Lab2_Bracket matching

14227 - 2024_IDS_Spring_Lab2_Bracket matching   

Description

You are given n string, each string Si consisting of parentheses '(', ')', '[' and ']'.
A string S is said to be *correct* if:
1. S is the empty string
2. A and B are correct, S = AB
3. A is correct, S = (A) or S = [A]

Judge each of n string is *correct* or not. If yes, print a line "Y". Otherwise, print a line "N".

Input

The first line contains an integer n — the total number of string you have to judge it is correct or not.

Each of the following n lines contains a string Si.

Restrictions

  • 1 ≤ n ≤ 103
  • 1 ≤ ∣Si∣ ≤ 104 for i=1,2,⋯ ,n
  • For testcase 1, 1 ≤ n ≤ 10,1 ≤ ∣Si∣ ≤ 102

Output

For each string, output one line following problem description.

Please add a newline at the end of the output. (Beside the last case)

Sample Input  Download

Sample Output  Download

Tags




Discuss