using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Text; using System.Text.RegularExpressions; using System.Linq; class Magatro { static int N = int.Parse(Console.ReadLine()); static void Main() { for (int i = 0; i < N; i++) { string S = Console.ReadLine(); Console.WriteLine(Hantei(S)); } } static string Hantei(string s) { int gcnt = 0; int rcnt = 0; for (int i = 0; i < s.Length; i++) { if (s[i] == 'G') gcnt++; if (s[i] == 'R') rcnt++; if (rcnt > gcnt) return "impossible"; } if (gcnt != rcnt||gcnt==0) return "impossible"; else return "possible"; } }