#include using namespace std; bool f(string s){ int w=0,g=0,r=0,R=0; for(auto x :s)R+=x=='R'; bool ok=1; for(auto x :s){ if(x=='G'){ g++; ok&=w>=g+r;} else if(x=='R'){g--;r++;ok&=g>=0;} else{w++; ok&=r+g>T; while(T--){ string s;cin>>s; if(!f(s))cout<<"im"; cout<<"possible"<