#include using namespace std; int main(){ ios::sync_with_stdio(false), cin.tie(nullptr); int T; cin >> T; while(T--){ string S; cin >> S; int cr = 0, cg = 0, cw = 0; bool ok = true; reverse(S.begin(), S.end()); for(auto c : S){ if(c=='R') cr++; else if(c=='G'){ if(cr==0) ok = false; else cr--, cg++; } else{ if(cg==0 and cw == 0) ok = false; else if(cg) cg--, cw++; } } if(cr or cg) ok = false; if(ok) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }