#include using namespace std; int T, N; string S; bool rec(int number = 0){ if(number == N) return true; int r = 0, g = 0, w = 0; int flag = false; if((r = S.rfind("R")) != string::npos && S.find("G", r) == string::npos && S.find("W", r) == string::npos){ if((g = S.rfind("G", r)) != string::npos && S.find("W", g) == string::npos){ if((w = S.rfind("W", g)) != string::npos){ S[r] = S[g] = S[w] = 'A'; flag = rec(number + 1); } } } return flag; } int main(void){ cin >> T; int i, j, k, p; for(i = 0; i < T; ++i){ cin >> S; j = k = p = 0; while((p = S.find("G", p)) != string::npos && p <= S.size()){ ++j; ++p; } p = 0; while((p = S.find("R", p)) != string::npos && p <= S.size()){ ++k; ++p; } if(j != k){ cout << "impossible" << endl; } else{ N = j; if(rec()){ cout << "possible" << endl; } else cout << "impossible" << endl; } } return 0; }