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; char last = ' '; for (int i = 0; i < s.Length; i++) { if (s[i] == 'G') gcnt++; if (s[i] == 'R') gcnt--; else last = s[i]; if (gcnt < 0) return "impossible"; } if (gcnt == 0 && last == 'G') return "possible"; else return "impossible"; } }