using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace shibasu { class Program { private static int IsShibusPossible(string arg) { string local_arg = arg; int W_pos = local_arg.IndexOf("W"); int G_pos = local_arg.IndexOf("G"); int R_pos = local_arg.IndexOf("R"); if (G_pos == -1 && R_pos == -1) { return 1; } if (W_pos == -1 || G_pos == -1 || R_pos == -1) { return -1; } if(W_pos > G_pos || W_pos > R_pos) { return -1; } if (G_pos > R_pos) { return -1; } local_arg = local_arg.Remove(local_arg.IndexOf("W"), 1); local_arg = local_arg.Remove(local_arg.IndexOf("G"), 1); local_arg = local_arg.Remove(local_arg.IndexOf("R"), 1); return IsShibusPossible(local_arg); } static void Main(string[] args) { string s = Console.ReadLine(); string[] t = s.Split(' '); int num = int.Parse(t[0]); for(int i = 0; i < num; i++) { if (IsShibusPossible(t[i+1]) == 1) { Console.WriteLine("possible"); } else { Console.WriteLine("impossible"); } } } } }