import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { char[] arr = sc.next().toCharArray(); int count = 0; for (char c : arr) { if (c == 'G') { count++; } else if(c == 'R') { count--; } if (count < 0) { break; } } if (count != 0) { sb.append("impossible"); } else { sb.append("possible"); } sb.append("\n"); } System.out.print(sb); } }