import java.util.*; import java.awt.geom.*; import java.io.*; public class Main { static int[] vx = {1,0,-1,0}; static int[] vy = {0,1,0,-1}; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); for(int i = 0; i < T; i++) { char[] in = sc.next().toCharArray(); int ws = 0; int gs = 0; int rs = 0; boolean ok = true; for(int j = 0; j < in.length; j++) { if(in[j] == 'R') rs++; else if(in[j] == 'G') gs++; else if(in[j] == 'W') ws++; if(gs > ws) ok = false; if(rs > gs) ok = false; } if(gs != rs) ok = false; System.out.println((ok?"possible":"impossible")); } } }