import java.util.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { char[] arr = br.readLine().toCharArray(); int r = 0; int g = 0; int w = 0; boolean type = true; for (int j = arr.length - 1; j >= 0; j--) { if (arr[j] == 'W') { if (g > 0) { g--; w++; } else if (g == 0 && w == 0) { type = false; break; } } else if (arr[j] == 'G') { if (r == 0) { type = false; break; } r--; g++; } else { r++; } } if (r > 0 || g > 0) { type = false; } if (type) { sb.append("possible"); } else { sb.append("impossible"); } sb.append("\n"); } System.out.print(sb); } }