#include <bits/stdc++.h>
using namespace std;
int main(){
	int t;	cin>>t;
	while(t--){
		string s;	cin>>s;
		int line=0;
		int white=0,red=0,green=0;
		bool possible=true;
		if(s.size()<3)	possible=false;
		for(int i=(int)s.size()-1;i>=0;i--){
			if(s[i]=='R')	red++;
			else if(s[i]=='G'){
				green++;
				line++;
				if(green>red){	possible=false;	break;	}
			}
			else{
				white++;
				line=max(0,line-1);		
				if(green*red==0){	possible=false;	break;	}
			}
		}
		if(line!=0||white<green||green!=red)	possible=false;
		if(possible)	cout<<"possible"<<endl;
		else 	cout<<"impossible"<<endl;
	}
	return 0;
}