#include <stdio.h>#include <string.h>#define LOCALcharstr[130];
charstack[130];
intmain()
{
inti, j, n;
intlen;
inttop;
#ifndef LOCALfreopen("c://uva_in.txt", "r", stdin);
#endifscanf("%d", &n);
getchar();
for (i=0; i<n; i++)
{
gets(str);
len=strlen(str);
if (len==0)
{
printf("Yes/n");
continue;
}
stack[0] =str[0];
top=0;
for (j=1; j<len; j++)
{
if (str[j] =='('||str[j] =='[')
stack[++top] =str[j];
elseif (str[j] ==')')
{
if (top>=0&&stack[top] =='(')
--top;
elsestack[++top] =str[j];
} else {
if (top>=0&&stack[top] =='[')
--top;
elsestack[++top] ==str[j];
}
}
if (top==-1)
printf("Yes/n");
elseprintf("No/n");
}
return0;
}