import java.util.*; public class Exercise129{ public static void main (String[] args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 0; i < n; i++){ judge(sc.next()); } } private static void judge(String s){ char[] sa = s.toCharArray(); if(sa.length < 3){ impossible(); return; } if(sa[sa.length - 1] != 'R' || sa[sa.length - 2] == 'W'){ impossible(); return; } int[] count = new int[3]; boolean hasG = false; for(int i = sa.length - 1; i >= 0; i--){ if(sa[i] =='R'){ count[0]++; }else if(sa[i] == 'G'){ hasG = true; count[1]++; }else if(sa[i] == 'W' && !hasG){ impossible(); return; } } if(count[0] != count[1]){ impossible(); return; } for(int i = sa.length - 1; i >= 0; i--){ if(sa[i] == 'R'){ boolean isGExist = false; for(int j = i - 1; j >= 0; j--){ if(sa[j] == 'G'){ isGExist = true; sa[j] = 'x'; boolean isWExist = false; for(int k = j - 1; k >= 0; k--){ if(sa[k] == 'W'){ isWExist = true; sa[k] = 'x'; break; }else if(k == 0 && !isWExist){ impossible(); return; } } break; }else if(j == 0 && !isGExist){ impossible(); return; } } } } System.out.println("possible"); } private static void impossible(){ System.out.println("impossible"); } }