#include #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; void solve(){ string s; cin>>s; while(!s.empty()){ int n=s.length(); if(s[n-1]!='R'){ puts("impossible"); return; } vector del(n); del[n-1]=true; int phase=0; for(int i=n-2;i>=0;i--){ if(phase==0 && s[i]=='G'){ del[i]=true; phase=1; } else if(phase==1 && s[i]=='W'){ del[i]=true; } } if(phase==0){ puts("impossible"); return; } string t; rep(i,n) if(!del[i]) t+=s[i]; s=t; } puts("possible"); } int main(){ int q; scanf("%d",&q); rep(_,q) solve(); return 0; }