Apex has given a riddle to Praggu and DR for the cryptocrux competition to be held tomorrow at CSE department. However they haven't been able to solve it yet. Can you?
Given a string .Check if you can reduce the brackets if the string is a balances parantheses. Reduction Rule A string is said to be reducible if on replacing a pair of consecutive opening and closing braces with '[' and ']' respectively in a parantheses string , the string remains balanced.
Input:
first line contains the number of testcases n
For next n lines, Each line contains a string i.e. a sequence of parantheses.
Output:
Output for each testcase "Yes" if the string is both balanced and reducible and "No" if the string is either not reducible or not balanced or both on a new line.
Constraints:
1<=n<=1000
1<=(length of string)<=100000
String symbol set = { ' ( ' , ' ) ' }
Example:-
Equivalent form of ( ( ) ( ) ) is [ ) ( ] which is not balanced and hence non-reducible.
Equivalent form of ( ( ( ) ( ) ( ) ) ) is [ ( ) ( ) ( ) ] which is balanced and hence reducible.