#include int main(void) { int i, j, t; int g, r; char s[1001]; scanf("%d", &t); for(i = 0;i < t;i++){ scanf("%s", s); g = 0; r = 0; j = 0; while(s[j] != '\0'){ if(s[j] == 'G')g++; if(s[j] == 'R')r++; if(r > g){ break; } j++; } if(s[j] == '\0' && r == g){ printf("possible\n"); } else{ printf("impossible\n"); } } return 0; }