using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Problem154 { class Program { static void Main(string[] args) { int T = int.Parse(Console.ReadLine()); string[] S = new string[T]; for (int i = 0; i < T; i++) S[i] = Console.ReadLine(); for(int i = 0; i < T; i++) { int wcount = 0; int gcount = 0; int wright = 0; int gright = 0; for(int j = 0; j < S[i].Length; j++) { char s = S[i][j]; if (s == 'W') { wcount++; wright = j; } else if(s == 'G') { gright = j; if(--wcount < 0) { Console.WriteLine("impossible"); break; } else { gcount++; } } else if(s == 'R') { if(--gcount < 0) { Console.WriteLine("impossible"); break; } } } if (wright >= gright) { Console.WriteLine("impossible"); } else { if (gcount == 0) { Console.WriteLine("possible"); } else if (gcount > 0) { Console.WriteLine("impossible"); } } } } } }