using System; using System.Linq; namespace No154_1{ public class Program{ public static void Main(string[] args){ Console.ReadLine(); string str; while((str = Console.ReadLine()) != null){ int cntW = 0, cntG = 0, cntR = 0; var possible = true; foreach(var c in str){ if(c == 'W') cntW++; if(c == 'G') cntG++; if(c == 'R') cntR++; if(cntW < cntG || cntG < cntR) possible = false; } if(cntG != cntR || str.Skip(str.LastIndexOf('G') + 1).Any(c => c == 'W')) possible = false; Console.WriteLine((possible ? "" : "im") + "possible"); } } } }