#include<bits/stdc++.h>
using namespace std;
int n,t[305];
string s;
string f(string s)
{
stack<char>st;
for(int i=0;i<s.size();i++)
{
if(t[s[i]]>0)
st.push(s[i]);
}
else
{
if(st.empty())
{
return "Wrong";
}
else
{
if(t[st.top()]+t[s[i]]==0)
{
st.pop();
}
else
{
return "Wrong";
}
}
}
}
if(st.empty())
{
return "OK";
}
else
{
return "Wrong";
}
}
int main()
{
t['(']=2;
t['[']=3;
t[')']=-2;
t[']']=-3;
cin>>n;
while(n--)
{
cin>>s;
cout<<f(s)<<endl;
}
return 0;
}
???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

