import java.util.Scanner; public class Main_yukicoder154 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int tcase = 0; tcase < t; tcase++) { char[] s = sc.next().toCharArray(); int n = s.length; boolean flag = true; int r = 0; int g = 0; int w = 0; // int dr = 0; // int dg = 0; // int dw = 0; for (int i = n - 1; flag && i >= 0; i--) { char c = s[i]; if (c == 'R') { r++; // dr++; } else if (c == 'G') { g++; // dg++; } else { w++; // dw++; } if (g > r) { flag = false; } if (w > 0 && g == 0) { flag = false; } if (w > 0 && g > 1) { w = 0; g--; r--; } } if (r != 1 || g != 1 || w == 0) { flag = false; } // System.out.printf("%d %d %d\n", dr, dg, dw); if (flag) { System.out.println("possible"); } else { System.out.println("impossible"); } } sc.close(); } }