#include using namespace std; int n; string s; bool solve(string s) { if(s.size()==0) return true; stack st; for(int i=0; i>n; while(n) { cin>>s; bool ok=solve(s); if(ok) cout<<"YES\n"; else cout<<"NO\n"; n--; } return 0; }