import java.util.*; public class Main { private static Scanner sc = new Scanner(System.in); public static void main(String[] args) throws Exception { int n = sc.nextInt(); for (int i = 0;i < n;i++) { if (solve(sc.next())) { System.out.println("possible"); } else { System.out.println("impossible"); } } } private static boolean solve(String s) { int w = 0; List g = new ArrayList<>(); List r = new ArrayList<>(); for (int i = s.length()-1;i >= 0;i--) { char c = s.charAt(i); if (c == 'W') { if (g.isEmpty() || r.isEmpty()) { return false; } else { w++; } } if (c == 'G') g.add(i); if (c == 'R') r.add(i); } if (g.size() != r.size()) return false; if (w < g.size()) return false; for (int i = 0;i < g.size();i++) { if (r.get(i) < g.get(i)) { return false; } } return true; } }