#include "bits/stdc++.h" using namespace std; #define print(x) cout< PI; typedef pair V; typedef vector VE; const ll mod = 1000000007; int main(){ int n; cin>>n; REP(i,n){ string s; cin>>s; int w=0; int g=0; int r=0; bool flag=1; int set=0; for(int j=s.size()-1;j>=0;j--){ if(s[j]=='G'){g++;} else if(s[j]=='R'){r++;} else if(s[j]=='W'){ w++; set=min(set+1,r); } if(w!=0&&g==0)flag=0; if(w!=0&&r==0)flag=0; if(r=g?"possible":"impossible"; print(ans); } }