#define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include ///////// #define REP(i, x, n) for(int i = x; i < n; i++) #define rep(i,n) REP(i,0,n) #define P(p) cout<<(p)<>T; int lenR,lenG,lenW; bool www=false; string ans[1000]; rep(i,T){ ans[i]=""; cin>>S; while(S.size() != 0){ lenR = S.size()-1; if(S[lenR]!='R'){ ans[i] = "im"; break; } S.replace(lenR,1,""); for(lenG=lenR-1;lenG>=0;--lenG){ if(S[lenG]=='G'){ S.replace(lenG,1,""); break; } } if(lenG < 0){ ans[i] = "im"; break; } for(lenW=lenG-1;lenW>=0;--lenW){ if(S[lenW]=='W'){ S.replace(lenW,1,""); www=true; } else{ break; } } if(www!=true){ ans[i] = "im"; break; }else{ www=false; } } ans[i] += "possible"; } rep(i,T){ P(ans[i]); } return 0; }