括号匹配
//括号匹配
#include<bits/stdc++.h>
using namespace std;
stack<char> st;
char a[10000][10000];
int main()
{
fill(a[0],a[0]+10000*10000,0);
for(int i=1;i<=6;i++)
{
scanf("%s",&a[i]);
}
for(int i=1;i<=6;i++)
{
bool judge=false;
for(int j=0;j<10000&&a[i][j]!='0';j++)
{
if(a[i][j]=='[')
{
st.push(a[i][j]);
}
else if(a[i][j]=='(')
{
st.push(a[i][j]);
}
else if(a[i][j]=='{')
{
st.push(a[i][j]);
}
else if(a[i][j]=='<')
{
st.push(a[i][j]);
}
if(a[i][j]==']')
{
char temp=st.top();
st.pop();
if(temp=='[')
{
judge=true;
}
else
{
printf("No\n");
continue;
}
}
else if(a[i][j]==')')
{
char temp=st.top();
st.pop();
if(temp=='(')
{
judge=true;
}
else
{
printf("No\n");
continue;
}
}
else if(a[i][j]=='}')
{
char temp=st.top();
st.pop();
if(temp=='{')
{
judge=true;
}
else
{
printf("No\n");
continue;
}
}
else if(a[i][j]=='>')
{
char temp=st.top();
st.pop();
if(temp=='<')
{
judge=true;
}
else
{
printf("No\n");
continue;
}
}
}
if(judge==true)
{
printf("Yes\n");
}
}
return 0;
}