#include using namespace std; int main(){ int t; cin>>t; while(t--){ //stack st; map mp; map ord; string x; cin>>x; int o=0; for(auto i:x){ mp[i]++; ord[i]+=o++; } if(mp['{']==mp['}'] and ord['{']