import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { char[] arr = new StringBuilder(sc.next()).reverse().toString().toCharArray(); int r = 0; int g = 0; int w = 0; for (char c : arr) { if (c == 'R') { r++; } else if (c == 'G') { if (r == 0) { r = -1; break; } r--; g++; } else { if (g == 0) { r = -1; break; } w = Math.min(w + 1, g); } } if (r == 0 && g == w) { sb.append("possible"); } else { sb.append("impossible"); } sb.append("\n"); } System.out.print(sb); } }