#include #include #include #include #include #include using namespace std; #define REP(i,n) for(int i=0;i<(n);++i) #define REPS(i,s,t) for(int i=(s);i<(t);++i) #define PER(i,n) for(int i=0;i>(n);--i) #define PERS(i,s,t) for(int i=(s);i>(t);--i) #define INF 2000000007 #define MINF -200000007 #define MOD 17 // 2^20 #define MAX 100005 typedef unsigned int uint; typedef unsigned long long int ull; typedef long long int ll; int dp[4912]; int main(){ int N;cin>>N; REP(i,N){ string str;cin>>str; bool flag = true; int cntw=0,cntr=0,pm=0 ; PERS(j,str.size()-1,-1){ if(str[j]=='R'){cntr++;pm++;} else if(str[j]=='G'){pm--;} else cntw++; if(pm<0) {flag = false;break;} } if(cntw < cntr) flag = false; cout << (flag ? "possible\n" : "impossible\n") ; } return 0; }