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; string s = Console.ReadLine(); int cnt = s.Length - s.Remove('G').Length; for (int j=0; j < s.Length; j++) { if (s[j] == 'G') g++; if (s[j] == 'R') r++; if (g == cnt && s[j] == 'W') { Console.WriteLine("impossible"); break; } if (r > g) { Console.WriteLine("impossible"); break; } if (j == s.Length - 1) { if (r == g) { if (!(s[j] == 'R')) Console.WriteLine("impossible"); else Console.WriteLine("possible"); } else Console.WriteLine("impossible"); } } } } }