// #pragma GCC optimize ("Ofast") // #pragma GCC optimize ("unroll-loops") // #pragma GCC target ("avx,avx2,fma") #include using std::cin, std::cout, std::cerr; using ll = long long; bool Solve() { std::string s; cin >> s; std::ranges::reverse(s); int cnt = 0; bool white = 0; for(char c : s) { if(c == 'R') cnt ++; else if(c == 'G') { if(cnt == 0) return false; cnt --; white = 1; } else { if(!white) return false; } } return cnt == 0; } int main() { std::ios::sync_with_stdio(false); int T; cin >> T; while(T --) { cout << (Solve() ? "possible" : "impossible") << '\n'; } }