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; foreach(char s in S[i]) { if (s == 'W') { wcount++; } else if(s == 'G') { if(--wcount < 0) { Console.WriteLine("impossible"); break; } else { gcount++; } } else if(s == 'R') { if(--gcount < 0) { Console.WriteLine("impossible"); break; } } } if(gcount == 0) { Console.WriteLine("possible"); } else if(gcount > 0) { Console.WriteLine("impossible"); } } } } }