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') { w[j]++; w1 = j; } else if(s.charAt(j) == 'G') { g[j]++; g1 = j; } else { r[j]++; } 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); } } }