using System; using System.Collections; using System.Collections.Generic; using System.Linq; class TEST{ static void Main(){ Sol mySol =new Sol(); mySol.Solve(); } } class Sol{ public void Solve(){ for(;T>0;T--){ String S=rs(); var ret = Check(S); Console.WriteLine(ret?"possible":"impossible"); } } int T; public Sol(){ T = ri(); } static bool Check(String S){ int wAll = S.Count(c => c == 'W'); int gAll = S.Count(c => c == 'G'); int rAll = S.Count(c => c == 'R'); if(gAll != rAll)return false; if(wAll < rAll)return false; int p = 0; int N = S.Length; for(int i=0;igRest){ w = gRest; } else { w--; } if(w<0)return false; } } if(w>0) return false; return true; } 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));} }