import java.util.Arrays; import java.util.HashSet; import java.util.LinkedList; import java.util.Scanner; import java.util.Set; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); final int T = sc.nextInt(); for(int tt = 0; tt < T; tt++){ final char[] input = sc.next().toCharArray(); LinkedList R_queue = new LinkedList(); LinkedList G_queue = new LinkedList(); boolean ok = true; for(int i = input.length - 1; i >= 0; i--){ if(input[i] == 'R'){ R_queue.add(i); }else if(input[i] == 'G'){ G_queue.add(i); }else if(input[i] == 'W'){ if(R_queue.isEmpty() || G_queue.isEmpty()){ ok = false; break; } } while(R_queue.size() >= 2 && G_queue.size() >= 2){ R_queue.remove(); G_queue.remove(); while(!G_queue.isEmpty() && G_queue.peek() > R_queue.peek()){ G_queue.remove(); } } if(R_queue.size() < G_queue.size()){ ok = false; break; } //System.out.println(i + " " + R_queue + " " + G_queue); } System.out.println(ok ? "possible" : "impossible"); } } }