#include int main(void) { int times, i, j, white, green, red; char bus[1001]; scanf("%d", ×); for (i = 0;i < times;i++) { scanf("%s", bus); j = white = green = red = 0; while (bus[j] != '\0') { if (bus[j] == 'W')white++; if (bus[j] == 'G')green++; if (bus[j] == 'R')red++; if ((white < green) || (green < red)) { goto IMPOSSIBLE; } j++; } if (green == 0 || red == 0 || bus[j-1]=='W' || green != red) { goto IMPOSSIBLE; } printf("possible\n"); continue; IMPOSSIBLE: printf("impossible\n"); continue; } return 0; }