import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		boolean tmp2;
		int T = sc.nextInt(), tmp1, tmp3, j;
		String S;
		for (int i = 0; i < T; ++i) {
			S = sc.next();
			tmp1 = 0;
			tmp2 = false;
			tmp3 = 0;
			for (j = 0; j < S.length(); ++j) {
				if (S.charAt(j) == 'W') {
					++tmp1;
					tmp2 = true;
				}
				else if (S.charAt(j) == 'G') {
					if (tmp1 == 0) break;
					--tmp1;
					tmp2 = false;
					++tmp3;
				}
				else {
					if (tmp3 == 0) break;
					--tmp3;
				}
			}
			if (j != S.length() || tmp2 || tmp3 != 0) System.out.println("impossible");
			else System.out.println("possible");
		}
		sc.close();
	}
}