#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++) using namespace std; typedef long long int ll; typedef vector VI; typedef pair PI; const double EPS=1e-9; bool solve(const string &s) { int n = s.length(); int w = 0, g = 0, r = 0; REP(i, 0, n) { switch(s[i]) { case 'W': w++; break; case 'G': g++; break; case 'R': r++; break; default: return 0; } if (w < g || w < r || g < r) { return 0; } } return g == r && g >= 1 && s[n - 1] == 'R'; } int main(void){ int t; cin >> t; REP (loop_var, 0, t) { string s; cin >> s; cout << (solve(s) ? "possible" : "impossible") << endl; } }