#include #include using namespace std; int main() { int t, wcount = 0, gcount = 0, rcount = 0; char s[1001]; cin >> t; for (int i = 1; i <= t; i++) { cin >> s; for (int j = 0; j < strlen(s); j++) { if (s[j] == 'W') { wcount++; } if (s[j] == 'G') { gcount++; } if (s[j] == 'R') { rcount++; } if (wcount < gcount || gcount < rcount) { cout << "impossible" << endl; goto END; } } if (gcount != rcount) { cout << "impossible" << endl; goto END; } cout << "possible" << endl; END:; wcount = 0; gcount = 0; rcount = 0; } }