using System; using System.Collections; using System.Collections.Generic; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ for(;T>0;T--){ String S=rs(); int r=0; int g=0; int w=0; bool chk=true; for(int i=S.Length-1;i>=0;i--){ if(S[i]=='R'){ r++; continue; } if(S[i]=='W'){ w++; if(r==0){chk=false;break;} if(g==0){chk=false;break;} continue; } if(S[i]=='G'){ g++; if(g>r){chk=false;break;} continue; } } Console.WriteLine( (chk&(r==g)&(r+g+w>=3))?"possible":"impossible"); } } int T; public Sol(){ T=ri(); } static String rs(){return Console.ReadLine();} static int ri(){return int.Parse(Console.ReadLine());} static long rl(){return long.Parse(Console.ReadLine());} static double rd(){return double.Parse(Console.ReadLine());} static String[] rsa(){return Console.ReadLine().Split(' ');} static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));} static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));} static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));} }