提交好久都不过QAQ
#include <cstdio>
#include <cstring>
#include <stack>
bool work(){
char a[131];std::stack<char> s;
scanf("%s",a);
if(!strlen(a)) return 1;
for(int i=0;a[i];i++){
if(a[i]=='('||a[i]=='[') s.push(a[i]);
else{
if(s.empty()||(a[i]==')'&&s.top()=='[')||(a[i]==']'&&s.top()=='('))
return 0;
s.pop();
}
}
return s.empty();
}
int main(){
int n;scanf("%d",&n);
while(n--) puts(work()?"Yes":"No");
return 0;
}