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; for (int i = n - 1; flag && i >= 0; i--) { char c = s[i]; if (c == 'R') { r++; } else if (c == 'G') { g++; } else { w++; } if (g > r) { flag = false; } if (w > 0 && g == 0) { flag = false; } if (c > 0 && g > 1) { w = 0; g--; r--; } } if (r != 1 || g != 1 || w == 0) { flag = false; } if (flag) { System.out.println("possible"); } else { System.out.println("impossible"); } } sc.close(); } }