#include template T in() { abort(); return T(); } template<> std::string in() { std::string str; std::cin >> str; return str; } template<> int in() { int x; scanf("%d", &x); return x; } template void out(T x) { abort(); } template<> void out(const char* x) { printf("%s\n", x); } template<> void out(std::string x) { std::cout << x << std::endl; } template<> void out(int x) { printf("%d\n", x); } template<> void out(long x) { printf("%ld\n", x); } bool check(std::string str) { if( str.size() < 2 ) return false; if( str[(int)str.size()-1] != 'R' ) return false; for(int i = (int)str.size() - 1; i >= 0; --i) { if( str[i] == 'G' ) break; if( str[i] == 'W' ) return false; } int nWr = 0, nG = 0, nR = 0; for(int i = 0; i < (int)str.size(); ++i) { if( str[i] == 'W' ) nWr += 1; if( str[i] == 'G' ) { nG += 1; nWr -= 1; if( nWr < 0 ) return false; } if( str[i] == 'R' ) nR += 1; if( not ( nR <= nG ) ) return false; } if( nR != nG ) return false; return true; } int main() { int n = in(); std::string str; for(int i = 0; i < n; ++i) { str = in(); out(check(str) ? "possible" : "impossible"); } return 0; }