注意用getline输入,可能是空串
#include <bits/stdc++.h>
using namespace std;
int n;
string str;
int main()
{scanf("%d", &n);getchar();while(n--){getline(cin, str);stack<int> s;for(int i = 0; i < str.size(); i++){if(s.size()){if(str[i] == ']' && s.top() == '[') s.pop();else if(str[i] == ')' && s.top() == '(') s.pop();else s.push(str[i]);}else s.push(str[i]);}if(s.size()) printf("No\n");else printf("Yes\n");}return 0;
}