#include #include #include using namespace std; int main() { int T; cin>>T; while (T--) { string s; cin>>s; reverse(begin(s), end(s)); int cnt[128]={}; bool res=true; for(auto& c: s) { ++cnt[c]; if (c=='W' and cnt['G']==0) res=false; else if (c=='G' and cnt['R']