#include #include #include using namespace std; #define RREP(i,s,e) for (i = e-1; i >= s; i--) #define rrep(i,n) RREP(i,0,n) #define REP(i,s,e) for (i = s; i < e; i++) #define rep(i,n) REP(i,0,n) int main() { int i, t; cin >> t; rep (i,t) { string s; int g = 0, r = 0, w = 0; cin >> s; for (auto c : s) { if (c == 'G') g++; else if (c == 'R') r++; else w++; } for (auto c : s) { if (c == 'G') g--; else if (c == 'R') r--; else if (g > 0) w--; if (g > r) break; } if (g == 0 && r == 0 && w == 0) cout << "possible" << endl; else cout << "impossible" << endl; } return 0; }