using System; using System.Linq; class Program { static void Main() { int t = int.Parse(Console.ReadLine()); for (int i=0;i< t; i++) { int g = 0, r = 0, w = 0; string s = Console.ReadLine(); for (int j=0; j < s.Length; j++) { if (s[j] == 'W') w++; if (s[j] == 'G') g++; if (s[j] == 'R') r++; int cntg = s.Length - s.Replace("G", "").Length; if (r > g || g > w || (g == cntg && s[j] == 'W')) { Console.WriteLine("impossible"); break; } if (j == s.Length - 1) { if (s[j] == 'R' && r == g && w >= g) Console.WriteLine("possible"); else Console.WriteLine("impossible"); } } } } }