import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i < t; i++) { String s = sc.next(); int len = s.length(); int[] w = new int[len]; int[] g = new int[len]; int[] r = new int[len]; int w1 = 0; int g1 = 0; int p = 0; for(int j = 0; j < len; j++) { if(s.charAt(j) == 'W') { if(j == 0) w[j]++; if(j > 0) w[j] = w[j - 1] + 1; w1 = j; } else if(s.charAt(j) == 'G') { if(j == 0) g[j]++; if(j > 0) g[j] = g[j - 1] + 1; g1 = j; } else { if(j == 0) r[j]++; if(j > 0) r[j] = r[j - 1] + 1; } if((w[j] < g[j]) || (g[j] < r[j])) p++; } String ans = "impossible"; if((p == 0) && (g[len - 1] == r[len - 1]) && (w1 < g1)) ans = "possible"; System.out.println(ans); } } }