#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin>>t; while(t--){ string s; cin>>s; int n=s.size(); int G=0,R=0; rep(i,n){ if(s[i]=='G') G++; else if(s[i]=='R') R++; } if(G!=R || G==0 || n-G-R=0;i--){ if(s[i]=='G'){ g++; w++; } else if(s[i]=='R') r++; else w=max(w-1,0); if(g>r){ b=false; break; } } if(b && w==0) cout<<"possible"<