#include #include using namespace std; int main(){ int t;cin>>t; while(t--){ string s;cin>>s; reverse(s.begin(),s.end()); int nw = 0; bool ok = false; bool ans = true; for(int i = 0; s.size() > i; i++){ if(s[i] == 'R')nw++; else if(s[i] == 'G'){ nw--; ok = true; if(nw < 0){ ans = false; break; } }else{ if(!ok){ ans = false; break; } } } cout << (ans?"possible":"impossible") << endl; } }